Created
January 13, 2019 11:13
-
-
Save Davisonpro/1195b06281624446db2573f4f7f2e2f9 to your computer and use it in GitHub Desktop.
Generate certificate
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
if ( ! fs.existsSync( key ) || ! fs.existsSync( certificate ) ) { | |
try { | |
execSync( 'openssl version', execOptions ); | |
execSync( | |
`openssl req -x509 -newkey rsa:2048 -keyout ./certs/key.tmp.pem -out ${ certificate } -days 365 -nodes -subj "/C=US/ST=Foo/L=Bar/O=Baz/CN=localhost"`, | |
execOptions | |
); | |
execSync( `openssl rsa -in ./certs/key.tmp.pem -out ${ key }`, execOptions ); | |
execSync( 'rm ./certs/key.tmp.pem', execOptions ); | |
} catch ( error ) { | |
console.error( error ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment