You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
greenkeeper[bot] 03f4b8e414 chore(package): update pem to version 1.14.1 6 years ago
src To keep things simple, only return key, cert, caCert 7 years ago
test Test keys.caCert validates SSL certificate 7 years ago
.gitignore Don't commit package-lock.json 7 years ago
.travis.yml Initial commit 7 years ago
LICENSE Initial commit 7 years ago
README.md Monthly downloads badge 7 years ago
package.json chore(package): update pem to version 1.14.1 6 years ago

README.md

create-cert

Super simple self signed certificates

Build Status Coverage Status npm npm

create-cert is a convenient wrapper around the pem module. It generates a self signed certificate with sensible defaults along with an associated CA certificate to validate against. It has a Promise based API and returns the keys in a format that can be passed directly into https.createServer.

Install

npm install --save create-cert

Usage

const createCert = require('create-cert');

createCert().then(keys => console.log(keys));
// {
//   key: '-----BEGIN RSA PRIVATE KEY-----\n...',
//   cert: '-----BEGIN CERTIFICATE-----\n...',
//   caCert: '-----BEGIN CERTIFICATE-----\n...'
// }

You can create a fully functioning HTTPS server like so:

createCert().then(keys => {
   https.createServer(keys, (req, res) => res.end('Hi!')).listen(443);
});

For strict SSL usage you can set the common name for the certificate and validate it against the CA certificate. An example using the Got request client:

createCert('foobar.com').then(keys => {
   https.createServer(keys, (req, res) => res.end('Hi!')).listen(443, () => {
     // This request will succeed without issues
     // as the SSL certificate will successfully
     // validate against the CA certificate.
     got('https://foobar.com', { ca: keys.caCert });
   });
});

API

createCert([options])

Returns a Promise which resolves to a keys object.

options

Type: string, object
Default: { days: 365, commonName: 'example.com' }

If a string is passed in, it will be used as the commonName. You can pass in any valid option for pem.createCertificate() to override the defaults.

License

MIT © Luke Childs