title: Keytool IOException when trying to convert JKS to PCKS12
body: <p>I have a JKS keystore that I want to convert to PCKS12 type, so I can later on export private key from it using openssl.
  The problem is, when I run the <code>keytool</code> command:</p>
  
  <pre><code>keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12 -srcstoretype JKS -deststoretype PKCS12 -srcstorepass pass -deststorepass pass -srcalias alias -destalias alias -srckeypass pass -destkeypass pass -noprompt
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>keytool error: java.io.IOException: DerInputStream.getLength(): lengthTag=109, too big.
  </code></pre>
  
  <p>I searched the Net looking for solution, and looks like it already happened to other people, but usually the problem was either in command or in source JKS keystore. Unfortunately, I cannot regenerate source JKS, also I have not other way to verify rather than </p>
  
  <pre><code>keytool -list -keystore keystore.jks
  </code></pre>
  
  <p>which returns valid result:</p>
  
  <pre><code>Keystore type: JKS
  Keystore provider: SUN
  
  Your keystore contains 1 entry
  
  key, 28.04.2017, PrivateKeyEntry,
  Certificate fingerprint (SHA1): ...
  </code></pre>
  
  <p>Am I doing something wrong? If not, is there any other way to export private key from JKS?</p>
  
  <p>Thanks</p>