I thinkint        X509_print(BIO *bp,X509 *x)may be helpful.
You could create a mem bio by BIO *BIO_new_mem_buf(void *buf, int len) with 
your own buffer.Then pass it to theX509_print function.


At 2011-02-26 07:44:59,"Cason, Kenny" <kenny.ca...@boeing.com> wrote:


Hiya!

 

I have an X509 data structure already loaded, and can use the built in routines 
to get the issuer, etc but what I need is the full text of the cert. The 
functionality I need is similar to the following command, except in C++:

$ openssl x509 -noout -in cert.pem -text

 

Here is the code so far:

 

int X509Authenticate::getCertAuthnLevel(char *userCertificate)

{

 X509 *x509=NULL;

 X509_NAME *issuer_name=NULL;

 char x509_issuer[500];

 

 // initialize openssl

 SSL_library_init();

 SSL_load_error_strings();

 

 // create bio from certificate

 BIO *mem;

 mem = BIO_new_mem_buf(userCertificate, -1);

 

 // load X509 structure

 X509_free(x509);

 X509 = PEM_read_bio_X509(mem, NULL, 0, NULL);

 

 if (x509 != NULL)

   {

     // get issuer

     issuer_name = X509_get_issuer_name(x509);

     char *issuer = X509_NAME_oneline(issuer_name,x509_issuer,500);

     m_ehandle->logDebug("getCertAuthnLevel | issuer=%s", issuer);

 

      // get full text

     ????

   }

 

Return 0;

}

 

Thanks in advance,

-Kenny

Information Security:

Identity Management & Authorization Controls
kenny.ca...@boeing.com

206-550-0049

 

Reply via email to