c++ - C++/OpenSSL 将 PEM 加载到 STACK_OF(X509)
问题描述
我正在加载一个PEM
(BIO
从文件或直接从用户输入)。此 PEM 可以包含堆叠的 1 到 N 个证书。
我找不到可以STACK_OF(X509*)
从我的简历PEM_read_bio_X509
中获得 a 的功能,就像单个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);
推荐阅读
- python - 将多个函数应用于同一列
- c - 为什么此 printList 函数不适用于 C 中的链接列表
- r - R - 如何导入带有块的巨大 .csv?
- spring-boot - 从嵌入式 Teiid 服务器访问表元数据
- kendo-ui - Kendo DataSource 捕获服务器响应
- c# - 为什么我的 Azure HTTP 触发器函数返回的数据比我指定的输出模型多?
- javascript - 播放全屏时,视频触摸事件不会在 iOS Safari 上触发
- excel - 如何通过首先查询 MAx 列并添加 1 来将 excel 数据导出到 MS Access?
- android - 如何修复我的相机谷歌地图android工作室
- kubernetes - Pod 无法从私有 Docker 注册表中提取图像