-
Notifications
You must be signed in to change notification settings - Fork 790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert x509 DER encoded to PEM #246
Comments
Using the public key specific API (which will set the appropriate PEM headers for you), the code looks about like this: var forge = require('forge');
var fs = require('fs');
var der = fs.readFileSync('/publickey.der', {encoding: 'binary'});
var asn1 = forge.asn1.fromDer(der);
var publicKey = forge.pki.publicKeyFromAsn1(asn1);
var pem = forge.pki.publicKeyToPem(publicKey); Doing generic DER to PEM, where you must set the PEM headers, etc.: var forge = require('forge');
var fs = require('fs');
var der = fs.readFileSync('/publickey.der', {encoding: 'binary'});
var msg = {
type: 'PUBLIC KEY', // you specify this header for the data
body: der
};
var pem = forge.pem.encode(msg); |
Thank you very much, it works like a charm! |
Sure :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I am looking for a way to convert from DER to PEM, the equivalent of
The text was updated successfully, but these errors were encountered: