本文介绍了以编程方式使用OpenSSL的提取PEM证书信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用openssl命令行能够提取,以人类可读的方式中,包含在质子交换膜证书的所有信息;那就是:
Using the openssl command line is possible to extract, in a human readable mode, all the information contained in a .pem certificate; that is:
openssl x509 -noout -in <MyCertificate>.pem -text
什么是为了使用OpenSSL的API来提取这些信息的适当的步骤?
What are the suitable steps in order to extract this information using the openssl API?
问候,
推荐答案
的 X509_print_ex
系列函数是你的答案。
The X509_print_ex
family of functions is your answer.
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/bio.h>
int main(int argc, char **argv)
{
X509 *x509;
BIO *i = BIO_new(BIO_s_file());
BIO *o = BIO_new_fp(stdout,BIO_NOCLOSE);
if((argc < 2) ||
(BIO_read_filename(i, argv[1]) <= 0) ||
((x509 = PEM_read_bio_X509_AUX(i, NULL, NULL, NULL)) == NULL)) {
return -1;
}
X509_print_ex(o, x509, XN_FLAG_COMPAT, X509_FLAG_COMPAT);
}
这篇关于以编程方式使用OpenSSL的提取PEM证书信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!