Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
361 views
in Technique[技术] by (71.8m points)

c - 从证书以ASN.1格式获取DN(Get DN from certificate in ASN.1 format)

I'm trying to get the DN from a certificate in ASN.1/DER format.

(我正在尝试从ASN.1 / DER格式的证书获取DN。)

I have searched OpenSSL but still cannot find the exact function to get the DN.

(我已经搜索过OpenSSL,但仍然找不到确切的功能来获取DN。)

Does anyone have any experience regarding this or can point me to books or any website?

(是否有人对此有任何经验,或者可以将我指向书籍或任何网站?)

  ask by Acan1234 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I already found a way to do this.

(我已经找到了一种方法。)

I just put here if anyone want to do the same.

(如果有人要这样做,我就放在这里。)

X509_NAME * cert_entry = X509_get_issuer_name(cert);    
unsigned char buff[100] = {0};
unsigned char * p = buff;
int i = i2d_X509_NAME(cert_entry,&p);

for(int b = 0;b<i;b++)
{       
    printf("%02X ",buff[b]);
}

This will print an hexa format.

(这将打印六进制格式。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...