How do I convert an XML RSA key to a PEM file?
For those who want the resulting PEM to be readable by BouncyCastle:
- use XMLSec2PEM tool to get a pem file
- convert pem to pkcs8 and back (!)
The final solution I am happy with:
java XMLSec2PEM my.xml > my.pem
- edit
my.pem
manually a bit org.bouncycastle.openssl.PEMReader.readObject()
returnsnull
:-(openssl pkcs8 -topk8 -inform pem -in my.pem -outform pem -nocrypt -out my.pkcs8
openssl pkcs8 -inform pem -nocrypt -in my.pkcs8 -out my.pkcs8.pem
- now
my.pkcs8.pem
is readable with thePEMReader