JSPM

mkcert-geek-fork

1.2.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q17599F
  • License MIT

Create Self Signed Development Certificates

Package Exports

  • mkcert-geek-fork

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mkcert-geek-fork) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Create self signed ssl certificates without OpenSSL.

Install

npm install -g mkcert

CLI

Create a Certificate Authority

$ mkcert create-ca --help

  Usage: create-ca [options]

  Options:
    --organization [value]  Organization name (default: "Test CA")
    --country-code [value]  Country code (default: "US")
    --state [value]         State name (default: "California")
    --locality [value]      Locality address (default: "San Francisco")
    --validity [days]       Validity in days (default: 365)
    --key [file]            Output key (default: "ca.key")
    --cert [file]           Output certificate (default: "ca.crt")
    -h, --help              output usage information

Create a Certificate

$ mkcert create-cert --help

  Usage: create-cert [options]

  Options:
    --ca-key [file]     CA private key (default: "ca.key")
    --ca-cert [file]    CA certificate (default: "ca.crt")
    --validity [days]   Validity in days (default: 365)
    --key [file]        Output key (default: "cert.key")
    --cert [file]       Output certificate (default: "cert.crt")
    --domains [values]  Comma separated list of domains/ip addresses (default: "localhost,127.0.0.1")
    -h, --help          output usage information

API

Create a Certificate Authority

import * as mkcert from 'mkcert';

//Create a Certificate Authority
mkcert.createCA({
  organization: 'Hello CA',
  countryCode: 'NP',
  state: 'Bagmati',
  locality: 'Kathmandu',
  validityDays: 365
})
.then((ca)=> {
  console.log(ca.key, ca.cert);
})
.catch(err=> console.error(err));

Create a Certificate

import * as mkcert from 'mkcert';
//Create a CA first

//Then create the certificate
mkcert.createCert({
  domains: ['127.0.0.1', 'localhost'],
  validityDays: 365,
  caKey: ca.key,
  caCert: ca.cert
})
.then((cert)=> {
  console.log(cert.key, cert.cert);

  //Create a full chain certificate by merging CA and domain certificates
  console.log(`${cert.cert}\n${ca.cert}`);
})
.catch(err=> console.error(err));