how to convert a ASN1_object to readable format using openssl library .?

certificate, openssl, ssl-certificate, x509, x509certificate

Solution

An ASN1_OBJECT is just OpenSSL's representation of an OID, an object identifier. If you only want to know it's OID, then:

ASN1_OBJECT *obj = X509_EXTENSION_get_object(ex); // ex is your X509_EXTENSION *
char buff[1024];
OBJ_obj2txt(buff, 1024, obj, 0); // 0 means it will prefer a textual representation (if available) rather than the numerical one

Then buf will contain a C string with the OID.

Regards.

Problem

X509_extension structure have a variable of ASN1_object . i want to read what is the content in that . Can any one tell me how to do that

Original source