我有一个带有自签名证书的 openssl X509 结构.我需要从此结构中获取 PEM 格式的 C++ 字符串.我需要使用哪些 openssl API 来实现这一目标?
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?
我尝试遵循 https 上的示例程序://www.codeblog.org/gonzui/markup/openssl-0.9.8a/demos/x509/mkcert.c.该程序展示了一种将 PEM 格式的证书写入文件的方法.如果没有其他方法,我可以将此文件的内容读入 C++ 字符串.
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.
查看 openssl x509 命令的源码,看看它是如何执行读取 DER 编码文件并写入 PEM 的操作的 - 即:
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
cli utils 的代码很容易理解
The code of the cli utils is pretty easy to follow
这篇关于如何使用openssl将PEM编码的X509证书作为C++字符串获取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!