DEV Community

loading...
Cover image for How to get HTTPS working on localhost

How to get HTTPS working on localhost

Konstantin Bogomolov
Web Developer | PHP Certified | Digital Nomad
・1 min read

The simplest way is to use mkcert utility.

It is easy to use tool for making local development SSL/TLS certificates.

Installation

At first, you need to install it. You can download a binary file from here to use it immediately without installation. Or follow the installation guide for your OS.

Usage

Run command to create local CA (Certificate Authority).

mkcert -install
Enter fullscreen mode Exit fullscreen mode

Run command to create certificate files.

mkcert localhost
Enter fullscreen mode Exit fullscreen mode

That's it.

You have two SSL certificate files now: *.pem which is a certificate file and *key.pem which is a key file.

Use these files in the configuration of your local webserver.

If you want to know how to generate it manually, read the How to get HTTPS working on localhost article on my website. The article has a simple Nginx example of configuration to use generated SSL certificate.

Discussion (0)