Share via


屬性架構

下列介面可用來將屬性新增至憑證要求:

架構遵循在 PKCS #10 認證要求語法的 ASN.1 模組中定義的架構。

CertificationRequestInfo ::= SEQUENCE 
{
   version                 CertificationRequestInfoVersion,
   subject                 ANY,
   subjectPublicKeyInfo    SubjectPublicKeyInfo,
   attributes              [0] IMPLICIT Attributes
}

Attributes ::= SET OF Attribute

Attribute ::= SEQUENCE 
{
   type       EncodedObjectID,
   values     AttributeSetValue
}

ICryptAttributes集合會對應至屬性欄位,而集合中的每個ICryptAttribute物件都會對應至 ASN.1屬性結構。

每個 Attribute 都包含物件識別碼 (OID) ,以及與 OID 相關聯的零個或多個值。 單一 OID 值組是由 IX509Attribute 介面表示。 您可以使用 IX509Attributes 集合來初始化 ICryptAttribute 物件,但集合中的每個屬性都必須與相同的 OID 相關聯。 一般而言,屬性只有一個值。

您可以使用下列任何衍生自 IX509Attribute的介面來建立單一 OID/value 屬性組:

例如,下列程式示範如何建立 ClientId 屬性。

若要建立 ClientId 屬性

  1. IX509CertificateRequestPkcs10IX509CertificateRequestCmc物件擷取ICryptAttributes物件。
  2. 建立並初始化 IX509AttributeClientId 物件。
  3. 建立 IX509Attributes 集合,並新增 IX509AttributeClientId 物件。
  4. 使用 IX509Attributes 集合來初始化 ICryptAttribute 物件。
  5. ICryptAttribute 物件新增至步驟 1 中擷取的集合。

下列範例顯示 ClientId 屬性的 ASN.1 輸出。 屬性包含產生要求 (test3d.jdomcsc.nttest.microsoft.com) 的電腦 DNS 名稱、使用者 SAM 名稱 (JDOMCSC\administrator) ,以及產生要求 (certreq) 的應用程式名稱。

0136: 30 57; SEQUENCE (57 Bytes)
0138: |  06 09                            ; OBJECT_ID (9 Bytes)
013a: |  |  2b 06 01 04 01 82 37 15  14
      |  |     ; 1.3.6.1.4.1.311.21.20 Client Information
0143: |  |  31 4a                         ; SET (4a Bytes)
0145: |  |     30 48                      ; SEQUENCE (48 Bytes)
0147: |  |        02 01                   ; INTEGER (1 Bytes)
0149: |  |        |  09
014a: |  |        0c 23                   ; UTF8_STRING (23 Bytes)
014c: |  |        |  74 65 73 74 33 64 2e 6a  64 6f 6d 63 73 63 2e 6e 
015c: |  |        |  74 74 65 73 74 2e 6d 69  63 72 6f 73 6f 66 74 2e 
016c: |  |        |  63 6f 6d                                         
      |  |        |     ; "test3d.jdomcsc.nttest.microsoft.com"
016f: |  |        0c 15                   ; UTF8_STRING (15 Bytes)
0171: |  |        |  4a 44 4f 4d 43 53 43 5c  61 64 6d 69 6e 69 73 74 
0181: |  |        |  72 61 74 6f 72                                   
      |  |        |     ; "JDOMCSC\administrator"
0186: |  |        0c 07                   ; UTF8_STRING (7 Bytes)
0188: |  |           63 65 72 74 72 65 71                             
      |  |              ; "certreq"

ICryptAttribute

ICryptAttributes

IX509Attribute

IX509Attributes