easy-local-ssl

Easily generate a self signed SSL for local development

Usage no npm install needed!

<script type="module">
  import easyLocalSsl from 'https://cdn.skypack.dev/easy-local-ssl';
</script>

README

easy-local-ssl

Automatic self signed SSL generation for local development (MacOS/Windows).
Powered by devcert.

NPM JavaScript Style Guide


screenshot


Install

npm install --save easy-local-ssl

Examples

Check out the examples folder:


Usage

const generateSslCert = require("easy-local-ssl");

// in your webpack config
const ssl = await generateSslCert();

...

// https://webpack.js.org/configuration/dev-server/#devserverhttps
devServerConfig.https = {
    key: ssl.key,
    cert: ssl.cert,
};

Advanced Usage

The generateSslCert method accepts an options object.

Property Description Default value Type
domain custom domain for the auto generated ssl certificate "localhost" string
modifyHostsFile modifying your /etc/hosts file for custom domains? true boolean

// specify a custom domain
const ssl = await generateSslCert({
    domain: "local.myapp.com",
    modifyHostsFile: true
});

License

MIT © patricktran