title: Get private key from PEM
body: <p>PEM file content.I have the passphrase of PEM file as well.</p>
  
  <pre><code>*Bag Attributes
      localKeyID: 12 7B 3C 4C ... 
  subject=/C..OTHER FIELDS
  -----BEGIN CERTIFICATE-----
  ...
  -----END CERTIFICATE-----
  Bag Attributes
      localKeyID: 12 7B 3C 4C ..
  Key Attributes: &lt;No Attributes&gt;
  -----BEGIN ENCRYPTED PRIVATE KEY-----
  ...
  -----END ENCRYPTED PRIVATE KEY-----*
  </code></pre>
  
  <p>I am able to extract certificate from PEM file with command.</p>
  
  <pre><code>openssl x509 -outform der -in client.pem -out your-cert.crt
  </code></pre>
  
  <p>But I am not able to extract private key.Tried below listed commands. OpenSSL hangs for both the commands. Am I missing something obvious here ?</p>
  
  <pre><code>openssl pkey -in client.pem -out key.pem
  </code></pre>
  
  <p>I need to extract client cert and key file to create <code>SSLSocketFactory</code> object in java.</p>