On 2/16/2012 5:53 PM, Iñaki Baz Castillo wrote:
> Hi, after the SSL/TLS handshake from a client I want to get the
> client's certificate(s) in PEM format (so I get a string I can print
> somewhere).
>
> So I do:
>
> X509 *client_cert;
> if ((client_cert = SSL_get_peer_certificate(ssl))) {
> # Printf got cert in PEM format
> }
>
> Now my question is: how can I get the PEM string of the client's certificate(s)?
>
> Thanks a lot.
>
I think the PEM formatting (a line with dashes, the
Base64 lines and another line with dashes) is currently
tied to writing and reading files via the BIO layer.
So you would have to set up a "memory" BIO handle, then
tell the X509 routines to save the certificate in PEM
format to your memory BIO handle.
Of cause if you just want to print it to stdout or
another real file handle, you could just use a BIO
pointing to that file handle.
--
Jakob Bohm, CIO, partner, WiseMo A/S.
http://www.wisemo.com
Transformervej 29, 2730 Herlev, Denmark. direct:
+45 31 13 16 10
<call:
+4531131610>
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded