1. create-cert
Super simple self signed certificates
create-cert
Package: create-cert
Created by: lukechilds
Last modified: Tue, 14 Jun 2022 02:52:36 GMT
Version: 1.0.6
License: MIT
Downloads: 4,468
Repository: https://github.com/lukechilds/create-cert

Install

npm install create-cert
yarn add create-cert

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

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin