【发布时间】:2015-03-10 15:22:07
【问题描述】:
在使用内存 BIO 时,我在访问签名的 CMS_ContentInfo* 对象内的 EnvelopedData 时遇到问题。
使用以下代码,一切正常:
BIO* output = BIO_new_file("/absolute/path/test.txt", "r+");
if (CMS_verify(cms, stack, store, dcont, output, CMS_NOINTERN)) {
BIO_flush(output);
BIO_reset(output);
CMS_ContentInfo* cms2 = SMIME_read_CMS(output, nullptr);
}
cms2 已正确实例化,我能够解密其内容。虽然,我不希望将文件写入磁盘,所以我试图像这样在内存中进行这项工作:
BIO* output = BIO_new(BIO_s_mem());
if (CMS_verify(cms, stack, store, dcont, output, CMS_NOINTERN)) {
BIO_flush(output);
BIO_seek(output, 0);
CMS_ContentInfo* cms2 = SMIME_read_CMS(output, nullptr);
}
由于某种原因,SMIME_read_CMS 函数似乎永远无法从BIO 中读取。谁能帮我解决这个问题?
【问题讨论】: