【发布时间】:2015-09-09 10:46:08
【问题描述】:
我尝试解密 PKCS7 数据,但在方法 "pkcs7.decrypt(key, cer)" 上总是收到错误 OpenSSL::PKCS7::PKCS7Error - wrong content type。
示例:
cer = OpenSSL::X509::Certificate.new(File.read("path/cert.cer"))
key = OpenSSL::PKey::RSA.new(File.read("path/private.key"), "111111")
crypted_data = File.read('path/pkcs7') # contains xml-file and signature "-----BEGIN PKCS7----- ... -----END PKCS7-----"
pkcs7 = OpenSSL::PKCS7.new(crypted_data)
decrypted_data = pkcs7.decrypt(key, cer) # error is here
需要帮助!如何从加密字符串中获取数据?
更新: 在 bash 上,我可以通过以下代码解决此任务:
openssl smime -verify -noverify -inform PEM -nointern -certfile "path/cert.cer" -CAfile "path/cert.cer" < path/pkcs7
返回 xml 文件。
【问题讨论】: