openSSL 教程无法完全工作 - 可以签名但无法恢复原始文件

openSSL 教程无法完全工作 - 可以签名但无法恢复原始文件

我正在为参与 openSSL 作业的小组成员编写并测试一个小教程。我们有一堆 PDF 文件,我是 CA,每个人都应该向我发送一份签名的 PDF 文件以供我验证。

我告诉他们做以下事情(并且我自己也尝试这么做)

  • 申请并获取证书(我将跳过此部分)
  • 创建包含 PDF 文件的 MIME 消息makemime -c "text/pdf" -a "Content-Disposition: attachment; filename=”Elaborato.pdf" Elaborato.pdf > Elaborato.pdf.msg
  • 使用 openSSL 签名openssl smime -sign -in Elaborato.pdf.msg -out Elaborato.pdf.p7m -certfile ca.pem -certfile nomegruppo.crt -inkey nomegruppo.key -signer nomegruppo.crt

  • 验证openssl smime -verify -in Elaborato.pdf.p7m -out Elaborato-verified.msg -CAfile ca.pem -signer nomegruppo.crt

  • 使用以下方式提取附件munpack Elaborato-verified.msg
  • 使用 Acrobat Reader 查看

问题是,即使我得到一个文件(从其二进制内容来看)类似于 PDF 文件,我当前的 Ubuntu PDF 查看器也无法读取它。munpackXXXElaborato.pdf提取的文件比原始文件小一点。

这个程序有什么问题理论上,他们应该向我发送签名的 S/MIME 消息,这样我就能够读取其中的 PDF。为什么我无法恢复 PDF 文件的原始内容

答案1

MIMEtext/pdf类型错误。应该是application/pdf,顺便说一句,我使用了mpackmakemime 而不是 makemime。

这使得文档签名教程有效

相关内容