i have a custom extension with test oid 1.2.3.4.5. I try to extract the oid
data in the following manner:
        int custom_nid=OBJ_create("1.2.3.4.5","sampleAlias","sample");
        int custom_idx=X509_get_ext_by_NID(cert,custom_nid,-1);
        X509_EXTENSION *extension=X509_get_ext(cert,custom_idx);
        ASN1_OCTET_STRING *octet_str=X509_EXTENSION_get_data(extension);
        const unsigned char *octet_str_data=octet_str->data;
        long xlen;
        int tag, xclass;
        int ret = ASN1_get_object(&octet_str_data, &xlen, &tag, &xclass,
octet_str->length);
        printf("value:%s\n",octet_str_data);

This is the value that gets printed:
.@{"volumeID":"12345978787","role":"write","clusterGUID":"999999"}

On investigating i found that ASN1 String was encoded in the form that it
had 04 at the start to denote ASN1 coding followed by the length of the
bytes and later my json string. However ASN!_get_object was taking 04 to be
a tag value and stripping it off but was not stripping off the length which
gave me a .@ extra at the start. How do i solve this problem? Is it
necessary that ASN1 String has to have to a tag? Am I decoding the extension
value correctly?

Thanks,
Jimit Shah




--
View this message in context: 
http://openssl.6102.n7.nabble.com/Extracting-data-from-custom-extension-tp45834.html
Sent from the OpenSSL - User mailing list archive at Nabble.com.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to