c2h*_*2h2 22 ubuntu command-line openssl digital-signature
嗨,我已生成密钥对,并使用私钥生成签名.
openssl rsautl -sign -in helloworld.txt -inkey aa.pem -out sig
Run Code Online (Sandbox Code Playgroud)
但是,我无法使用我的公钥验证签名:
openssl rsautl -verify -in helloworld.txt -inkey aa.pub -sigfile sig
Run Code Online (Sandbox Code Playgroud)
我知道-sigfile已被弃用.openssl.org的一些在线文档是错误的.
什么命令我应该使用我的公钥来验证信号?
M'v*_*'vy 56
我找到了两个问题的解决方案.
您可以这样使用rsautl :(使用私钥:my.key和公钥my-pub.pem)
$ openssl rsautl -sign -inkey my.key -out in.txt.rsa -in in.txt
Enter pass phrase for my.key:
$ openssl rsautl -verify -inkey my-pub.pem -in in.txt.rsa -pubin
Bonjour
Run Code Online (Sandbox Code Playgroud)
使用此方法,所有文档都包含在签名文件中,并由最终命令输出.
但就我而言,我的证书上写着:签名算法:sha1WithRSAEncryption.因此,我建议您使用4个步骤签署文档的标准方法:(此方法用于所有非对称电子签名,以免对签名文件和/或CPU使用过度收费)
OpenSSL分两步完成:
$ openssl dgst -sha256 -sign my.key -out in.txt.sha256 in.txt
Enter pass phrase for my.key:
$ openssl dgst -sha256 -verify my-pub.pem -signature in.txt.sha256 in.txt
Verified OK
Run Code Online (Sandbox Code Playgroud)
使用此方法,您向收件人发送了两个文件:原始文件纯文本,签名文件签名摘要.注意:签名文件不包含整个文档!只有摘要.
| 归档时间: |
|
| 查看次数: |
78530 次 |
| 最近记录: |