Skip to content

How to get the "green padlock" using the built in certificate

Tim edited this page Apr 24, 2018 · 10 revisions

Tested on Chrome on macOS. Feel free to add instructions to this page for Windows, Linux or other browsers.

Locate the built-in certificate

Possible locations:

  • local-web-server is installed globally
    • /usr/local/lib/node_modules/local-web-server/node_modules/lws/ssl/lws-cert.pem on macOS and Linux.
    • %AppData%\npm\node_modules on Windows 7+
  • local-web-server is installed locally
    • ./node_modules/lws/ssl/lws-cert.pem

Node Version Manager

If you're using nvm, your installation directory may be different.

  1. $ nvm which current
  2. $ open that directory
  3. Follow back that directory until you get to your active version directory (v#.##.#)
  4. Go to ./lib/node_modules/local-web-server/node_modules/lws/ssl

If you're using the default NVM install location, you can also just run: $ open ~/.nvm/versions/node/v8.11.1/lib/node_modules/local-web-server/node_modules/lws/ssl/

Trust the certificate (macOS)

You must add the new certificate to your machine's trusted certificate store. On macOS, this is done via the Keychain Assistant.

  1. Open Keychain Assistant
  2. Import the certificate
  3. Open it and select "Always trust"

Trust the Certificate (Ubuntu)

Follow the instructions at https://leehblue.com/add-self-signed-ssl-google-chrome-ubuntu-16-04/ to trust a certificate on Ubuntu

Trust the Certificate (Chrome for Windows)

Follow the instructions at http://www.nullalo.com/en/chrome-how-to-install-self-signed-ssl-certificates/ tl;dr:

  1. Start your local web server in https mode and browse to the site
  2. Click Advanced > Proceed to localhost (unsafe)
  3. Press F12 to open dev tools
  4. Click on the security tab, then click on View Certificate
  5. Click the details tab then Copy to File
  6. Click "Next", then Cryptographic Message Syntax Standard – PKCS #7 Certificates (.P7B), then "Next" again
  7. Save the certificate somewhere accessible, like the Desktop
  8. Open Chrome Settings > Show advanced settings… > HTTPS/SSL > Manage certificates… > Import
  9. Click "Next", browse to the certificate you exported in step 7.
  10. Click "Place all certificates in the following store", then click "Browse" and select Trusted Root Certification Authorities.
  11. Click "OK", then "Next", then "Finish"
  12. Restart Chrome

Launch the secure server

$ ws --https
Serving at https://mbp.local:8000, https://127.0.0.1:8000, https://192.168.0.100:8000

If you navigate to https://127.0.0.1:8000 you will now see the green lock.

Clone this wiki locally