【问题标题】:OpenSSL smime verify failed with right certificate and signatureOpenSSL smime 验证失败,证书和签名正确
【发布时间】:2013-07-04 02:10:31
【问题描述】:

我收到加密和签名的 smime 消息。 解密没问题,数据好像是正确的。

openssl.exe smime -decrypt -in %1 -out %1_signed.txt -inkey myPrivate.pem

但在验证签名阶段出现错误。

openssl.exe smime -verify -CAfile senderCACert.pem -certfile senderCert.pem -in %1 -out %1_plain

Verification failure
7600:error:21071065:PKCS7 routines:PKCS7_signatureVerify:digest failure:./crypto/pkcs7/pk7_doit.c:9
48:
7600:error:21075069:PKCS7 routines:PKCS7_verify:signature failure:./crypto/pkcs7/pk7_smime.c:312:

发送两个证书(CA 证书和客户端证书)应该没问题。

我认为 openssl 可以在解密过程中产生特定符号,例如换行符或源消息中不存在的其他符号。或者它可以处理非标准算法(至少据我所知openssl有非标准的私钥存储格式)

我使用 openssl 0.9.8h。而另一端的smime消息是由“webMethods EDI version 6.5”软件(处理EDI消息的AS2服务器)形成的。

这个错误的原因是什么?

您能建议尝试其他 smime 工具吗?

【问题讨论】:

    标签: openssl signature actionscript-2 edi smime


    【解决方案1】:

    [简介] 感谢您的问题 ;-) 我终于花了一些时间来正式确定如何使用 OpenSSL 调试我的 AS2 通信。

    [背景] (1) 我正在开发 BabelAS2 - http://code.google.com/p/babelas2/ - EDIINT AS2 (RFC 4130) 标准传输协议的开源 VBScript 实现。我使用 CAPICOM 作为密码库。 (2) 我想检查如何使用来自http://www.shininglightpro.com 的“Win32 OpenSSL v0.9.8q”来调试加密部分;-)

    [SOLUTION#1] 解密 HTTP 负载:

    1. 在 HTTP 有效负载的转储顶部手动添加以下文本

      MIME-Version: 1.0
      Content-Disposition: attachment; filename="smime.p7m"
      Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"
      Content-Transfer-Encoding: base64
      [CRLF]
      
    2. 然后,你可以使用:

      openssl smime -decrypt -inkey "Server.pair-of-keys.pem" -in "HTTP-Payload.encrypted.txt.with-manually-added-header.txt" -out "decrypted.with-OpenSSL.txt"
      

    [SOLUTION#2] 非常符合解密消息的签名:

    1. 随便用

      openssl.exe smime -verify -in "decrypted.with-OpenSSL.txt" -CAfile "Client.cer"
      

    如果对你有帮助,请告诉我...

    【讨论】:

    • 谢谢。我已经解决了这个问题并在这里描述:stackoverflow.com/questions/3975612/…
    • @Donz,感谢您的反馈和链接,如果我对“应用程序/EDI”有任何疑问,我会记住的 ;-)
    猜你喜欢
    • 2018-03-09
    • 2012-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-19
    相关资源
    最近更新 更多