Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Importing P12 File
Anchor
Importing-P12-File
Importing-P12-File

Key Steps

  1. Create a new Keystore.

  2. Empty the Keystore.

  3. Verify if the Keystore is empty.

  4. Import the P12 file.

  5. Check the Keystore is non-empty.

  6. Change the alias, if needed.

  7. Verify a new alias.

To perform the above steps, open a Command Prompt window. The steps along with the requisite syntax are described in detail below:

Step 1 - Create New Keystore
Anchor
Step-1
Step-1

  •  Execute the following command at the Command Prompt

...

Note

The same key password will be used in the subsequent steps.

Step 2 - Empty the Keystore
Anchor
Step-2
Step-2

  • Execute the following command at the Command Prompt:

    Code Block
    keytool -delete -alias <alias name> -keystore <keystore name>
    
    Example: 
    keytool -delete -alias demoalias1 -keystore demokeystore1
  • Enter the password as given in Step 1.

Step 3 - Verify if Keystore is Empty
Anchor
Step-3
Step-3

  • Execute the following command at the Command Prompt:

    Code Block
    keytool -v -list -keystore <keystre name>
    
    Example: 
    keytool -v -list -keystore demokeystore1
  • Enter password as given in Step 1.

The response should be "Your keystore contains 0 entries".

Step 4 - Import the P12 file
Anchor
Step-4
Step-4

  • Execute the following command at the Command Prompt:

    Code Block
     keytool -v -importkeystore -srckeystore <p12file.p12> -srcstoretype PKCS12 -destkeystore <keystore name> -deststoretype JKS -destkeypass <password for private key (should be same as keystore passphrase)>
    
    Example: 
    keytool -v -importkeystore -srckeystore sample_p12_file.p12 -srcstoretype PKCS12 -destkeystore demokeystore1 -deststoretype JKS -destkeypass demoPassword1

  • Enter the destination Keystore password given in Step 1.

  • Enter the source Keystore password that was obtained while generating P12 file.

The response should be "Import command completed: 1 entries successfully imported, 0 entries failed or canceled".

Step 5 - Check Keystore to be Non-empty
Anchor
Step-5
Step-5

  • Execute the following command at the Command Prompt:

    Code Block
    keytool -v -list -keystore <keystre name>
    
    Example: 
    keytool -v -list -keystore demokeystore1
  • Enter password as given in Step 1.

...

Steps 6 & 7 are needed if you want to change the alias for the imported private key.

Step 6 - Change Alias if needed
Anchor
Step-6
Step-6

  • Execute the following command at the Command Prompt:

...

The response will be blank if the change is successful.

Step 7 - Verify New Alias
Anchor
Step-7
Step-7

  • Repeat Step 5 and ensure the alias name is what is given in Step 6.

...