title: PFX to JKS keytool conversion: Alias <*> does not exist
body: <p>I'm trying to convert x.PFX file to x.JKS file using keytool but I am getting following error:</p>
  
  <pre><code>keytool error: java.lang.Exception: Alias &lt;2&gt; does not exist
  </code></pre>
  
  <p>Actions that preceded this error are:</p>
  
  <p><strong>Listing x.PFX file content (just to read alias name):</strong> </p>
  
  <pre><code>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.
  </code></pre>
  
  <p><strong>Converting x.PFX file into x.JKS file using "2" as source alias name</strong></p>
  
  <pre><code>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 &lt;2&gt; does not exist
  </code></pre>
  
  <p>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?</p>