Created
May 2, 2017 23:09
-
-
Save miguelmota/4b17772a2ea46b1b07e4402b741023c2 to your computer and use it in GitHub Desktop.
Node.js get certificate contents only using regular expression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs.readFile('./certs/client.crt', 'utf8', (error, data) => { | |
const re = /[\s\S]*-----BEGIN CERTIFICATE-----\n([\s\S]*)\n-----END CERTIFICATE-----[\s\S]*/gi; | |
const cert = data.replace(re, '$1'); | |
console.log(cert); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment