I'm using crypto
module to validate a certificate, but both, my certificate and my public key are in DER format. It seems that crypto
module does not accept this format.
Is there a way (or module) to convert DER to PEM format using NodeJS? I couldn't find any and cannot use command line to call openssl via shell.
UPDATE: It's not about HTTPS certificates. It's about general X.509 certificates. And if you mark the question as negative, please leave a comment to justify it. Don't be a stupid if you are not able to help.
Dominykas' answer was good, but in my case, I have a certificate that uses ECC and node-forge
does not support it.
So I've found a module called node-openssl-wrapper
, which worked perfectly well because it encapsulates the openssl commands in a simple function call, like this:
co(function*() {
var ossl = require('openssl-wrapper');
var derCert = new Buffer('...'); // binary DER certificate
var pemCert = yield ossl.qExec('x509', derCert, { inform: 'der', outform: 'pem' });
});