使用以下属性创建 CSR 时出错:主题中的 "T" 和 "uidNumber"

Error when creating CSR with the attributes: "T" and "uidNumber" in the subject

对于我们将在工作中进行的集成,我们需要向当地政府组织提供证书签名请求文件。这家本地公司在生成CSR文件时需要在主题中有以下属性:

CN=data/O=data/OU=data/T=data/C=AU/dnQualifier=data/uidNumber=data/uid=data/serialNumber=data/emailAddress=john@example.com

当我使用以下命令使用 OpenSSL 生成 CSR 文件时:

$ openssl req -new -key example.pem -out example.csr -subj "{the above subject}"

我得到下一个错误:

req: Skipping unknown attribute "T"                                     
req: Skipping unknown attribute "uidNumber"    

我在 Debian 9.5 和 Ubuntu 18.04 上试过,结果相同。

经过调查,我在 /etc/ssl/openssl.cfg 文件中添加了新的 OID:

[ new_oids ]
uidNumber = 1.2.3.4
T = 1.2.3.4.2

终于顺利生成了。

在验证 CSR 文件时,我能够在主题中看到 TuidNumber 属性:

$ openssl req -in example.csr -noout -text

虽然我通过更新 OpenSSL 配置文件获得了主题中的属性,但我真的不确定我在定义它们时使用的 1.2.3.41.2.3.4.2 值的含义(我只是按照文件中注释示例的模式)。尽管属性按预期存在,但这些值是否会影响我将要使用的 CSR 文件?

非常感谢您的帮助。

I am really not sure of the meaning of 1.2.3.4 and 1.2.3.4.2 values I used when defining them

通常情况下,这些 OID 具有相关各方都能理解的含义。通常,它们的值和含义会在某个已知位置发布。查找它们的便捷站点是 this OID repository。您选择的 OID 没有已知含义。

Does those values affect the CSR file I am going to use although the attributes are present as expected?

是的,OID 将成为 PEM 或 DER 编码的 CSR 的一部分,并由接收方用来解析文件。事实上, OIDs 被包括在内,而不是属性本身的名称。使用您选择的 OID,接收方将无法理解关联值的含义。因此,您应该确保选择与属性的预期含义相匹配的 OID 值。

T 属性可能指的是 title with OID 2.5.4.12, for which the short name T can be used. That short name does not seem to be standardized, but see the ITU X.520 spec 部分 6.4.3 title,其中以 T = "Manager, Distributed Applications" 为例。

uidNumber属性可能指的是OID 1.3.6.1.1.1.1.0.

但是,与其猜测编写您正在使用的规范的人的意图,不如请求将 OID 添加到其中,最好是为所有属性添加。这样一来,各方就可以确切地知道预期的属性 OID 是什么以及如何解释关联的值。