How to create a certificate into a PKCS12 keystore with keytool?

David García González picture David García González · Jan 17, 2013 · Viewed 67.6k times · Source

I wanted to create a certificate into a PKCS12 keystore format with keytool program.

The keystore has extension .pfx.

How do I achieve this?

Answer

David García González picture David García González · Jan 17, 2013

If the keystore is PKCS12 type (.pfx) you have to specify it with -storetype PKCS12 (line breaks added for readability):

keytool -genkey -alias <desired certificate alias> 
    -keystore <path to keystore.pfx>
    -storetype PKCS12 
    -keyalg RSA 
    -storepass <password> 
    -validity 730 
    -keysize 2048