无法读取 s/mime 格式的 PKCS7 签名文件(大尺寸)
我想验证 s/mime 格式的签名文件,pkcs7 文件大小为 500MB。
openssl smime -verify -in test.pk7 -inform DER
读取 S/MIME 消息时出错 715956256:错误:07069041:内存缓冲区例程:BUF_MEM_grow_clean:malloc失败:buffer.c:152: 715956256:错误:0D06B041:asn1编码例程:ASN1_D2I_READ_BIO:malloc失败:a_d2i_fp.c:229:
是否可以使用有限的内存使用例如200MB?
I want to verify signed file with s/mime format and the pkcs7 file size is 500MB.
openssl smime -verify -in test.pk7 -inform DER
Error reading S/MIME message
715956256:error:07069041:memory buffer routines:BUF_MEM_grow_clean:malloc failure:buffer.c:152:
715956256:error:0D06B041:asn1 encoding routines:ASN1_D2I_READ_BIO:malloc failure:a_d2i_fp.c:229:
Is it possible with limited memory usage e.g.200MB ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不幸的是,OpenSSL 会将整个文件加载到内存中。
如果可能的话,切换 PKCS#7 分离签名将显着减少内存需求。这意味着将数据和签名作为两个单独的文件。
Unfortunately, OpenSSL will load the whole file in memory.
If possible switching PKCS#7 detached signatures would reduce significantly the memory requirements. That means having the data and the signature as 2 separate files.
我遇到了一个 1.4GB 加密文件的问题,在 32 位主机上它在 malloc 上失败,在 64 位上它通过了。
I had this problem with a 1.4GB encrypted file, on 32bit host it failed on mallocs, on 64bit it got through.
正如 Mathias 提到的,如果签名被分离,您可以在 OpenSSL 中流式处理数据。
现在,如果您的签名没有分离,您应该仍然可以自己分离它。 PKCS#7 格式有详细记录。 asn1c 可以分块工作,所以你应该能够使用它。
当然,正确的解决方案是首先获得独立的签名。
As Mathias mentions, you can stream process the data in OpenSSL if the signature is detached.
Now if your signature isn't detached, you should still be able detach it yourself. The PKCS#7 format is well-documented. asn1c can work in chunks so you should be able to work with that.
Of course, the proper solution is to get a detached signature in the first place.
我使用了支持基于块的处理的 NSS 库,并且它运行得很好。
I have used NSS library which supports chunk-based processing and it worked perfectly.