Generate keystore with PKCS12 format using keytool of Java

PKCS12 is one of the standard formats of SSL certificates with high-security capabilities. Java’s keytool tool in addition to helping us to generate JKS keystore for Java, also supports us to generate this PKCS12 certificate.

Specifically, you can use the following command to generate PKCS12 certificates with keytool:

The meaning of each of the above parameters, you can refer to the tutorial Generate keystore using keytool in Java. The only difference is that we have to declare the -storetype parameter with the value PKCS12.

The extension of the PKCS12 certificate file can be .p12 or .pfx!

For example, I can generate a PKCS12 certificate with the following command:

Result:

You need to enter the password to ensure the integrity of the keystore file (see the -storepass option in the tutorial Generate keystore using keytool in Java) and then press Enter:

Re-enter the password and then press Enter again:

Answer some questions and then confirm. If all is correct, enter yes!

After generating, you can go to the directory passed in the command (mine is /Users/Khanh/Documents), enter the following command:

to check the result.

My example is as follows:

1/5 - (1 vote)

Add Comment