使用OpenSSL通过OID从X.509证书中提取自定义扩展

时间:2011-09-07 06:12:19

标签: openssl x509 asn.1

我已经能够通过索引从X.509证书中提取自定义扩展名:

X509_EXTENSION* ex = X509_get_ext(x509, extension_index);

如何通过OID而不是索引来提取扩展名?

1 个答案:

答案 0 :(得分:1)

使用以下内容:

int my_nid = OBJ_create("1.2.3.4", "MyShortObjectName", "My Long Object Name");
int my_idx = X509_get_ext_by_NID(x509, my_nid, -1);
X509_EXTENSION* ex = X509_get_ext(x509, my_idx);