属性体系结构

以下接口用于向证书请求添加属性:

体系结构遵循 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/值属性对:

例如,以下过程演示如何创建 ClientId 属性。

创建 ClientId 属性

  1. IX509CertificateRequestPkcs10IX509CertificateRequestCmc 对象检索 ICryptAttributes 对象。
  2. 创建和初始化 IX509AttributeClientId 对象。
  3. 创建 IX509Attributes 集合,并添加 IX509AttributeClientId 对象。
  4. 使用 IX509Attributes 集合初始化 ICryptAttribute 对象。
  5. ICryptAttribute 对象添加到步骤 1 中检索到的集合。

以下示例显示了 ClientId 属性的 ASN.1 输出。 该属性包含生成请求的计算机的 DNS 名称(test3d.jdomcsc.nttest.microsoft.com)、用户的 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