I want to convert DER content to PEM format using Nodejs.
I couldn't find any suitable library or logic. How can I achieve this?
I want to convert DER content to PEM format using Nodejs.
I couldn't find any suitable library or logic. How can I achieve this?
This is (now?) built directly into the Node.js crypto library.
const crypto = require( 'crypto' );
You can import a private key in DER format:
const key = crypto.createPrivateKey( { key: privkeyInDerFormat, format: 'der', type: 'pkcs8' } );
And then export it in PEM format:
const privkeyInPemFormat = key.export( { format: 'pem', type: 'pkcs8' } );
Done! :)