Get DN from certificate in ASN.1 format

百般思念 提交于 2020-01-25 21:06:15

问题


I'm trying to get the DN from a certificate in ASN.1/DER format. I have searched OpenSSL but still cannot find the exact function to get the DN.

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


回答1:


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.



来源:https://stackoverflow.com/questions/39634163/get-dn-from-certificate-in-asn-1-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!