Skip to content

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

Lloyd Brookes edited this page Jun 30, 2019 · 10 revisions

These instructions apply to Google Chrome. If you spot any mistakes please correct them.

macOS

1. Locate the built-in certificate

If local-web-server is installed globally.

  • /usr/local/lib/node_modules/local-web-server/node_modules/lws/ssl/lws-cert.pem.

If local-web-server is installed locally.

  • ./node_modules/lws/ssl/lws-cert.pem

If you're using nvm (Node Version Manager).

  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/

2. Trust the certificate

You must add the certificate to your machine's trusted certificate store via the Keychain Assistant.

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

3. 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.

Linux

1. Locate the built-in certificate

If local-web-server is installed globally.

  • /usr/local/lib/node_modules/local-web-server/node_modules/lws/ssl/lws-cert.pem.

If local-web-server is installed locally.

  • ./node_modules/lws/ssl/lws-cert.pem

If you're using nvm (Node Version Manager).

  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/

2. Trust the certificate

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

3. 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.

Windows

1. Locate the built-in certificate

If local-web-server is installed globally.

  • %AppData%\npm\node_modules on Windows 7+

If local-web-server is installed locally.

  • ./node_modules/lws/ssl/lws-cert.pem

2. Trust the certificate

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

  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

3. 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