title: Convert pfx formatted private key to pem format
body: <p>I have a private key (not very secret one) that is very likely in a pfx format. I need to convert it to a pem format, in order to use it in signatures.</p>
  
  <p>The key is in a one line. It doesn't have separate begin and end rows. It's in one line, base64 encoded, 2284 letters long (longer than regular x.509 that I have seen before). I got it with some other variables as well including:</p>
  
  <p>seed
  id
  compatibility</p>
  
  <p>I was able to see how it is created. It is created by first creating a </p>
  
  <blockquote>
    <p>java.security.cert.X509Certificate</p>
  </blockquote>
  
  <p>Then this is exported to a PFX format through a function.</p>
  
  <p>Inside that function I see Keystore instance "PKCS12" mentioned.
  Also ByteArrayOutputStream is seen.</p>
  
  <p>Any idea how I could convert this one lined base64 encoded private key to a pem format? That format should be accepted by the <strong>node module xmlCrypto</strong>, which I'm using for the signing. Currently the xmlCrypto gives following warning with the key:</p>
  
  <blockquote>
    <p>Error: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag</p>
  </blockquote>