Skip to content

Instantly share code, notes, and snippets.

@glasser
Created April 18, 2019 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glasser/8dd5498e824bad648ce3c8f7a2035c0a to your computer and use it in GitHub Desktop.
Save glasser/8dd5498e824bad648ce3c8f7a2035c0a to your computer and use it in GitHub Desktop.
const pem = require('pem');
const fs = require('fs');
let pemFile = fs.readFileSync(process.argv[2], 'utf8');
pemFile = pemFile.replace(/BEGIN PRIVATE KEY/, 'BEGIN RSA PRIVATE KEY');
pemFile = pemFile.replace(/END PRIVATE KEY/, 'END RSA PRIVATE KEY');
pem.getPublicKey(pemFile, function (err, result) {
if (err) {
console.error("ERROR", err);
} else {
console.log("ok");
}
});
{
"name": "pem-check",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"pem": "^1.8.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment