title: import encrypted private key to jks
body: <p>I need use ssl(2 way handshake) socket for connection in my project.
  So for creating keys, i used openssl with this comands :</p>
  
  <p>for server : </p>
  
  <pre><code>req -x509 -days 3650 -nodes -newkey rsa:2048 -keyout a_private.key -out a_certificate.cert
  
  rsa -in a_private.key -des3 -out a_private_des.key
  
  rsa -in a_private_des.key -pubout -out a_pub.key
  </code></pre>
  
  <hr>
  
  <p>for client :</p>
  
  <pre><code>req -x509 -days 3650 -nodes -newkey rsa:2048 -keyout b_private.key -out b_certificate.cert
  
  rsa -in b_private.key -des3 -out b_private_des.key
  
  rsa -in b_private_des.key -pubout -out b_pub.key
  </code></pre>
  
  <hr>
  
  <p>for import to jks file i used keytool:</p>
  
  <pre><code>keytool -import -alias a_private -file a_private_des.key -keystore a.jks
  
  keytool error: java.lang.Exception: Input not an X.509 certificate
  </code></pre>
  
  <p>after that, I made der file with this command :</p>
  
  <pre><code>pkcs8 -topk8 -in a_private_des.key -out a_private_des.der -outform DER
  </code></pre>
  
  <p>and retry to import key to jks file:</p>
  
  <pre><code>keytool -import -alias a_private -file a_private_des.der -keystore a.jks
  
  keytool error: java.lang.Exception: Input not an X.509 certificate
  </code></pre>
  
  <p>and I get same exception with b_pub.key</p>
  
  <hr>
  
  <p>how can I import encrypted private key and public key in jks file ?</p>
  
  <p>tanx alot.</p>