2012/2/16 <[email protected]>:
> well, I think the certificate is coded in base64. so write it to file, run
> openssl base64 -d -in file -out newfile
> and read the newfile in. or start parsing it an pipe the output to your
> application.
Well, this is to run within a server application so I cannot write to
a file neither use openssl in command line :)
However I've already got it:
X509 *client_X509;
unsigned char client_PEM_string[10*1024];
size_t client_PEM_string_len = sizeof(client_PEM_string);
BIO *bio;
int res;
if ((client_X509 = SSL_get_peer_certificate(ctx))) {
bio = BIO_new (BIO_s_mem());
res = PEM_write_bio_X509(bio, client_X509);
res = BIO_read(bio, client_PEM_string, (int)client_PEM_string_len);
client_PEM_string[res]='\0';
X509_free(client_X509);
printf("CERT:\n%s\n", client_PEM_string);
}
--
Iñaki Baz Castillo
<[email protected]>
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [email protected]