Verifying a Signature
First
Alice:
alice Creates a keystore, alice.certs, and generates a key pair with alias alice:
keytool -genkeypair -keystore alice.certs -alias alice
export a certificate file:
keytool -exportcert -keystore alice.certs -alias alice -file alice.cer
Bob:
When Bob receives the certificate, he can print it:
keytool -printcert -file alice.cer
he can import it into his keystore
keytool -importcert -keystore bob.certs -alias alice -file alice.cer
Second
Now Alice can start sending signed documents to Bob. The jarsigner tool signs and verifies JAR files. Alice simply adds the document to be signed into a JAR file.
jar cvf document.jar document.txt
Then she uses the jarsigner tool to add the signature to the file. She needs to specify the keystore, the JAR file, and the alias of the key to use
jarsigner -keystore alice.certs document.jar alice
When Bob receives the file, he uses the -verify option of the jarsigner program
jarsigner -verify -keystore bob.certs document.jar
本文详细介绍了Alice如何创建密钥库并生成密钥对,接着导出证书文件,并将其发送给Bob。Bob收到证书后进行导入,并验证由Alice签名的文档。整个过程使用了keytool和jarsigner工具。
1726

被折叠的 条评论
为什么被折叠?



