属性体系结构

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

体系结构遵循 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 集合对应于 attributes 字段,集合中的每个 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 输出。 属性包含 (test3d.jdomcsc.nttest.microsoft.com) 生成请求的计算机的 DNS 名称、用户 (JDOMCSC\administrator) 的 SAM 名称,以及生成请求的应用程序的名称 (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