Sometimes we have to develop applications that works with digital certificates.
Java platform has a rich set of tools and APIs that makes our life easier when we have the need to create a new certificate, digital keys, cryptograph a file or simply sign a document. I am going to show you below some commands that you can use in Keytool, which is a program contained in JDK that helps you to create digital keys.
1) Creating a new keystore:
keytool -genkey -keyalg RSA -keysize 1024 -alias developer-validity 1000 -keystore mykeystore.ks
This command creates a file called "mykeystore.ks" on the same folder where it is executed.
2) Exporting a certificate:
keytool -export -alias developer -file developer.cer -keystore mykeystore.ks
This command creates a file called "developer.cer", which contains the digital certificate related to the alias "developer".
3) Importing a certificate created by another person:
keytool -import -trustcacerts -file patrick.cer -alias patrick -keystore mykeystore.ks
This command imports the certificate "patrick.cer" with the alias "patrick" to our keystore.
No comments:
Post a Comment