I need to search the X509 text for certain values, usually contained in the 
Policies.
Using "X509_print" to obtain the text works in my test program but, for unknown 
reasons, that call crashes the "main" program that invokes my subroutine. So 
I'm looking for an alternate way to obtain the cert text that is searchable.

Here is what works in test but not called from the "main" program:

        bmem = BIO_new(BIO_s_mem());
        if (!(X509_print(bmem, X509cert))) {    <-- crashes at this call!
               print an error...
        }

        BUF_MEM *bptr;
        BIO_get_mem_ptr(bmem, &bptr);
        char *buffer = (char *)malloc(bptr->length);

        memcpy(buffer, bptr->data, bptr->length-1);
        buffer[bptr->length-1] = 0;

Here is the alternative I have so far:

     CERTIFICATEPOLICIES *cp;
     if ((cp = (CERTIFICATEPOLICIES*) X509_get_ext_d2i(X509cert, 
NID_certificate_policies, NULL, NULL)) == NULL) {
        printMsg("decodeX509cert: no policies found");
     } else {
        printMsg("decodeX509cert: found policies");
     }

The output shows "decodeX509cert: found policies" so I know the policies are 
there.
How do I convert cp into text that I can search using strstr or such?
Thanks,
-Kenny
Boeing IT: Information Security
Authorization Controls - Web Single Sign-On
kenny.ca...@boeing.com
206-550-0049

Reply via email to