I have a openssl X509 structure with a self signed certificate. I need to get a PEM formatted C++ string from this structure. What are the openssl APIs that I need to use to achieve this?
I tried following the example program at https://www.codeblog.org/gonzui/markup/openssl-0.9.8a/demos/x509/mkcert.c. This program shows a way to write the certificate in PEM format to a file. I can read the contents of this file into a C++ string if there is no other way to do it.
解决方案
look at the source of the openssl x509 command and see how it does the operation to read a DER encoded file and writes a PEM one - ie:
openssl x509 -in mycert.der -inform DER -out mycert.pem
The code of the cli utils is pretty easy to follow