Site icon Narayana Tutorial

Convert JKS to PKCS12

SelfSigned JKS file can be generated for a development environment but the JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry-standard format using “keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.jks -deststoretype pkcs12

Generate Self signed JKS


D:\>keytool -genkey -keyalg RSA -alias narayantutorial.com -keystore narayanatutorial.jks -storepass Admin1234 -validity 365 -keysize 2048
What is your first and last name?
  [Unknown]:  narayana tutorial
What is the name of your organizational unit?
  [Unknown]:  online java tutorial
What is the name of your organization?
  [Unknown]:  narayanatutorial
What is the name of your City or Locality?
  [Unknown]:  bangalore
What is the name of your State or Province?
  [Unknown]:  karnataka
What is the two-letter country code for this unit?
  [Unknown]:  in
Is CN=narayana tutorial, OU=online java tutorial, O=narayanatutorial, L=bangalore, ST=karnataka, C=in correct?
  [no]:  yes

Enter key password for <narayantutorial.com>
        (RETURN if same as keystore password):

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore narayanatutorial.jks -destkeystore narayanatutorial.jks -deststoretype pkcs12".

D:\>
Self Signed JKS Generation

narayanatutorial.jks file generated, now we can convert JKS to PKCS12 using the following command

keytool -importkeystore -srckeystore narayanatutorial.jks -destkeystore narayanatutorial_NEW.jks -deststoretype pkcs12

Convert JKS to PKCS12

Convert JKS to PKCS12
D:\>keytool -importkeystore -srckeystore narayanatutorial.jks -destkeystore narayanatutorial_NEW.jks -deststoretype pkcs12
Importing keystore narayanatutorial.jks to narayanatutorial_NEW.jks...
Enter destination keystore password:
Re-enter new password:
Enter source keystore password:
Entry for alias narayantutorial.com successfully imported.
Import command completed:  1 entries successfully imported, 0 entries failed or cancelled

D:\>

For more details click here