GithubHelp home page GithubHelp logo

create-cert's Introduction

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.

Related

License

MIT © Luke Childs

create-cert's People

Contributors

greenkeeper[bot] avatar lukechilds avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.