如何使用充气城堡在 CSR 中添加自定义 OID 和值
How to add custom OID and values in CSR using bouncy castle
我正在尝试像这样在 CSR 中添加自定义 OID
string subject = "CN=Name,O=Org,C=IN,ST=KA,OU=OrgUn,PostalCode=560103";
X509Name sub = new X509Name(subject);
var oidList = sub.GetOidList();
var valueList = sub.GetValueList();
DerObjectIdentifier Oid1 = new derObjectIdentifier("1.53.4.64");//here 1.53.4.64 is custom OID
oidList.Add(Oid1);
valueList.Add("Some Value");
DerObjectIdentifier Oid2 = new DerObjectIdentifier("1.53.4.65");
oidList.Add(derObjectIdentifier2);
valueList.Add("Some value");
X509Name subjectFinal = new X509Name(oidList, valueList);
Pkcs10CertificationRequestDelaySigned pkcs10 = new Pkcs10CertificationRequestDelaySigned(signatureAlgorihtm, subjectFinal, publicKeyParameters, null);
一切都编译并工作正常但是当我解码并检查 CSR 时,自定义 Oid 名称的 值从 1.53.4.65 更改为 ASN.1 中的其他值 2.13.4.64信息。
这是添加自定义 OID 值的正确方法吗
ASN.1 序列
SET {
16 11: SEQUENCE {
18 3: OBJECT IDENTIFIER commonName (2 5 4 3)
23 4: UTF8String 'Name'
: }
: }
29 12: SET {
31 10: SEQUENCE {
33 3: OBJECT IDENTIFIER organizationName (2 5 4 10)
38 3: UTF8String 'Org'
: }
: }
43 11: SET {
45 9: SEQUENCE {
47 3: OBJECT IDENTIFIER countryName (2 5 4 6)
52 2: PrintableString 'IN'
: }
: }
56 11: SET {
58 9: SEQUENCE {
60 3: OBJECT IDENTIFIER stateOrProvinceName (2 5 4 8)
65 2: UTF8String 'KA'
: }
: }
69 14: SET {
71 12: SEQUENCE {
73 3: OBJECT IDENTIFIER organizationalUnitName (2 5 4 11)
78 5: UTF8String 'OrgUn'
: }
: }
85 15: SET {
87 13: SEQUENCE {
89 3: OBJECT IDENTIFIER postalCode (2 5 4 17)
94 6: UTF8String '560103'
: }
: }
102 21: SET {
104 19: SEQUENCE {
106 3: OBJECT IDENTIFIER '2 13 4 64'
111 12: UTF8String 'Some value 1'
: }
: }
125 21: SET {
127 19: SEQUENCE {
129 3: OBJECT IDENTIFIER '2 13 4 65'
134 12: UTF8String 'Some value 2'
: }
: }
添加自定义 OID 属性的代码是正确的,但我们不能使用任何随机数作为 OID,它必须为 ex 1.3.6.1.4 注册。1.XXXX.X.X 或者它必须具有某种格式。
我正在尝试像这样在 CSR 中添加自定义 OID
string subject = "CN=Name,O=Org,C=IN,ST=KA,OU=OrgUn,PostalCode=560103";
X509Name sub = new X509Name(subject);
var oidList = sub.GetOidList();
var valueList = sub.GetValueList();
DerObjectIdentifier Oid1 = new derObjectIdentifier("1.53.4.64");//here 1.53.4.64 is custom OID
oidList.Add(Oid1);
valueList.Add("Some Value");
DerObjectIdentifier Oid2 = new DerObjectIdentifier("1.53.4.65");
oidList.Add(derObjectIdentifier2);
valueList.Add("Some value");
X509Name subjectFinal = new X509Name(oidList, valueList);
Pkcs10CertificationRequestDelaySigned pkcs10 = new Pkcs10CertificationRequestDelaySigned(signatureAlgorihtm, subjectFinal, publicKeyParameters, null);
一切都编译并工作正常但是当我解码并检查 CSR 时,自定义 Oid 名称的 值从 1.53.4.65 更改为 ASN.1 中的其他值 2.13.4.64信息。
这是添加自定义 OID 值的正确方法吗
ASN.1 序列
SET {
16 11: SEQUENCE {
18 3: OBJECT IDENTIFIER commonName (2 5 4 3)
23 4: UTF8String 'Name'
: }
: }
29 12: SET {
31 10: SEQUENCE {
33 3: OBJECT IDENTIFIER organizationName (2 5 4 10)
38 3: UTF8String 'Org'
: }
: }
43 11: SET {
45 9: SEQUENCE {
47 3: OBJECT IDENTIFIER countryName (2 5 4 6)
52 2: PrintableString 'IN'
: }
: }
56 11: SET {
58 9: SEQUENCE {
60 3: OBJECT IDENTIFIER stateOrProvinceName (2 5 4 8)
65 2: UTF8String 'KA'
: }
: }
69 14: SET {
71 12: SEQUENCE {
73 3: OBJECT IDENTIFIER organizationalUnitName (2 5 4 11)
78 5: UTF8String 'OrgUn'
: }
: }
85 15: SET {
87 13: SEQUENCE {
89 3: OBJECT IDENTIFIER postalCode (2 5 4 17)
94 6: UTF8String '560103'
: }
: }
102 21: SET {
104 19: SEQUENCE {
106 3: OBJECT IDENTIFIER '2 13 4 64'
111 12: UTF8String 'Some value 1'
: }
: }
125 21: SET {
127 19: SEQUENCE {
129 3: OBJECT IDENTIFIER '2 13 4 65'
134 12: UTF8String 'Some value 2'
: }
: }
添加自定义 OID 属性的代码是正确的,但我们不能使用任何随机数作为 OID,它必须为 ex 1.3.6.1.4 注册。1.XXXX.X.X 或者它必须具有某种格式。