繁体   English   中英

C++/OpenSSL 将 PEM 加载到 STACK_OF(X509)

[英]C++/OpenSSL load PEM into STACK_OF(X509)

我正在BIO加载PEM (从文件或直接从用户输入)。 此 PEM 可以包含 1 到 N 个堆叠的证书。

我无法从我的 bio 中找到一个给我STACK_OF(X509*)的函数,就像PEM_read_bio_X509对单个X509* PEM_read_bio_X509那样。

有这样的功能吗? 如果没有,我可以用另一种方式得到相同的结果吗?

这是@Reinier Torenbeek 提供的链接中的相关部分:

STACK_OF(X509_INFO) *certstack;
const char ca_filestr[] = "./cabundle.pem";

stackbio = BIO_new(BIO_s_file());
outbio   = BIO_new_fp(stdout, BIO_NOCLOSE);

/* ---------------------------------------------------------- *
 * Load the file with the list of certificates in PEM format  *
 * ---------------------------------------------------------- */
if (BIO_read_filename(stackbio, ca_filestr) <= 0) {
    BIO_printf(outbio, "Error loading cert bundle into memory\n");
    exit(-1);
}

certstack = PEM_X509_INFO_read_bio(stackbio, NULL, NULL, NULL);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM