PFX to JKS keytool conversion: Alias <*> does not exist

mrm picture mrm · Nov 11, 2012 · Viewed 44.1k times · Source

I'm trying to convert x.PFX file to x.JKS file using keytool but I am getting following error:

keytool error: java.lang.Exception: Alias <2> does not exist

Actions that preceded this error are:

Listing x.PFX file content (just to read alias name):

keytool -v -list -storetype pkcs12 -keystore x.pfx

Enter keystore password: x

Keystore type: PKCS12   
Keystore provider: SunJSSE

Your keystore contains 1 entry

Alias name: 2
Creation date: 11-nov-2012

Entry type: PrivateKeyEntry
Certificate chain length: 3
Certificate[1]:
Owner: CN=x, OU=x, C=x
Issuer: CN=x, O=x, C=x
Serial number: x
Valid from: Wed Oct 24 11:46:10 CEST 2012 until: Fri Dec 13 09:28:40 CET 2013
Certificate fingerprints:

etc.

Converting x.PFX file into x.JKS file using "2" as source alias name

keytool -importkeystore -srckeystore x.pfx -srcstoretype pkcs12 -srcalias 2 -destkeystore x.jks -deststoretype jks -destalias xyz
Enter destination keystore password: y
Re-enter new password: y
Enter source keystore password: x
keytool error: java.lang.Exception: Alias <2> does not exist

I am not sure what I am doing wrong? PFX file contain only one entry with just one alias (2). I also tried using these srcalias values: 2, "2", " 2". Is there any other way to convert PFX into JKS using keytool without knowing source alias name?

Answer

Richard Heller picture Richard Heller · Sep 5, 2014

I had the exact same problem. I've solved using '1' instead of 2. Don't know why but it worked.