包详细信息

devcert-san

davewasmer33.9kMIT0.3.3

Generate trusted local SSL/TLS certificates for local SSL development

ssl, certificate, openssl, trust

自述文件

devcert - Development SSL made easy

So, running a local HTTPS server usually sucks. There's a range of approaches, each with their own tradeoff. The common one, using self-signed certificates, means having to ignore scary browser warnings for each project.

devcert makes the process easy. Want a private key and certificate file to use with your server? Just ask:

import { createServer } from 'https';
import * as express from 'express';
import getDevelopmentCertificate from 'devcert';

async function buildMyApp() {
  let app = express();

  app.get('/', function (req, res) {
    res.send('Hello Secure World!');
  });

  let ssl;
  if (process.env.NODE_ENV === 'development') {
    ssl = await getDevelopmentCertificate('my-app', { installCertutil: true });
  } else {
    ssl = // load production ssl ...
  }

  return createServer(ssl, app).listen(3000);
}

Now open https://localhost:3000 and voila - your page loads with no scary warnings or hoops to jump through.

Certificates are cached by name, so two calls for getDevelopmentCertificate('foo') will return the same key and certificate.

installCertutil option

devcert currently takes a single option: installCertutil. If true, devcert will attempt to install some software necessary to tell Firefox (and Chrome on Linux) to trust your development certificates. This is not required, but without it, you'll need to tell Firefox to trust these certificates manually:

Firefox provides a point-and-click wizard for importing and trusting a certificate, so if you don't provide installCertutil: true to devcert, we'll instead open Firefox and kick off this wizard for you. Simply follow the prompts to trust the certificate. Reminder: you'll only need to do this once per machine

Note: Chrome on Linux requires installCertutil: true, or else you'll face the scary browser warnings every time. Unfortunately, there's no way to tell Chrome on Linux to trust a certificate without install certutil.

The software installed varies by OS:

  • Mac: brew install nss
  • Linux: apt install libnss3-tools
  • Windows: N/A

How it works

When you ask for a development certificate, devcert will first check to see if it has run on this machine before. If not, it will create a root certificate authority and add it to your OS and various browser trust stores. You'll likely see password prompts from your OS at this point to authorize the new root CA. This is the only time you'll see these prompts.

This root certificate authority allows devcert to create a new SSL certificate whenever you want without needing to ask for elevated permissions again. It also ensures that browsers won't show scary warnings about untrusted certificates, since your OS and browsers will now trust devcert's certificates. The root CA certificate is unique to your machine only, and is generated on-the-fly when it is installed.

License

MIT © Dave Wasmer

更新日志

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.3.2 (2017-04-28)

Bug Fixes

  • add -d flag to security command, not sure why it ignores -p otherwise, but oh well (842404f)

0.3.1 (2017-04-28)

Bug Fixes

  • wrap NSS db dir paths with quotes (69be0f7)

0.3.0 (2017-04-28)

Bug Fixes

  • fix waitForUser async usage (9fd27c5)

Features

  • add root CA setup versioning (6c80805)

0.2.20 (2017-04-28)

Bug Fixes

0.2.19 (2017-04-28)

Bug Fixes

  • warn user to quit firefox before root install (8bb0271)

0.2.18 (2017-04-27)

Bug Fixes

  • add required nickname arg to certutil command (5bc9874)

0.2.17 (2017-04-27)

Bug Fixes

  • trim newlines from discovered certutil path (f45195e)

0.2.16 (2017-04-27)

Bug Fixes

  • do not use ~ for home dir, use $HOME instead (faf1518)

0.2.15 (2017-04-27)

0.2.14 (2017-04-27)

0.2.13 (2017-04-27)

Bug Fixes

  • fix installCertutil handling (1a571e1)
  • silence openssl output (f66f558)

0.2.12 (2017-04-27)

0.2.11 (2017-04-27)

Bug Fixes

  • add eol conversion for openssl.conf on windows (f854a0e)
  • escape backslashes in conf template paths (2354eb0)

0.2.10 (2017-04-04)

Bug Fixes

  • use double quotes to avoid escaping issues on windows (08f4362)

0.2.9 (2017-04-04)

Bug Fixes

  • don't hardcode path separators in conf template (b7db54a)
  • fix quote marks -> template string (32f24f7)

0.2.8 (2017-03-31)

Bug Fixes

  • add -batch flag to avoid prompting (5ba2424)
  • add root ca cert to /etc/ssl/certs on linux (5dc37a4)

0.2.7 (2017-03-31)

Bug Fixes

  • do not block with execSync when launching firefox, template openssl conf to get config paths (2600a89)

0.2.6 (2017-03-31)

Bug Fixes

  • separate commands so each gets sudo, improve debug output (af40aca)

0.2.5 (2017-03-31)

0.2.4 (2017-03-30)

Bug Fixes

  • fix root key path when generating root cert (83c8672)

0.2.3 (2017-03-30)

Bug Fixes

  • make the config dir first (fab033a)

0.2.2 (2017-03-30)

Bug Fixes

  • fix configDir for non-windows (7457cde)

0.2.1 (2017-03-30)

Bug Fixes

  • don't ignore dist when publishing (eef1738)

0.2.0 (2017-03-30)

Features

  • improve Readme, return node.createServer compatible object, improve error messaging (b760220)

0.1.0 (2017-03-29)