How to Make SSL Certificates for Local Development

0 Comments
Editor Ratings:
User Ratings:




This tutorial explains how to make SSL certificates for local development. Here I will talk about a simple command line tool, mkcert which helps you create certificate for a specified name so you can run a HTTPS server locally on your PC. You just have to run 2 simple commands to create and install the certificate. After creating the certificates, you can move them to the application’s root and then start the server.

If you are developing some web application locally and want to test it on HTTPS connection then you can’t easily do that. Most web servers or HTTP servers normally create HTTP connection. But the tool here can help you create a HTTPS server by creating local certificates. This is useful in testing payment gateways or any other application that involves secure connection. You can create certificate for any name and then use that.

How to Make SSL Certificates for Local Development

How to Make SSL Certificates for Local Development?

Before starting with this tutorial, I assume that you have some knowledge of web servers. Here I will first show you how to obtain a certificate for any hostname or IP and then use it in action. To create a server I will use the the “http-server” in Node.js. The “http-server” can be run from any directory after installing it globally. It uses a PEM and CERT file that this tool, mkcert file generates. The following steps will guide you how to do that.

Step 1: Get the binary executables of mkcert from here and then put in some folder of your choice. After that, open a command prompt there and run the following command.

mkcert -install

mkcert install

Step 2: Now, run the following command to generate a certificate for the specified domains. After running this command, it will create two PEM files in the current directory.

mkcert example.com "*.example.org" myapp.dev localhost 127.0.0.1 ::1

mkcert tool certificates generated

Step 3: The certificate is not created and you can place the generated files in your application’s root directory. And since I am using “http-server” so it will use the names “key.pem” and “cert.pm” to create a HTTPS server. So simply rename the “example.com+5.pem” to “cert.pem”. And rename the “example.com+5-key.pem” file to “key.pem”. Next, start the server by running the following command in the specified syntax.

http-server "path to application" -p "post number" -S

Local HTTPS server in action

In this way, you can make SSL certificates for local development. And you can customize the above command according to your needs. In just a few seconds, you can create local certificates and use them to create a local HTTPS server.

Final thoughts

If you are looking for a simple ways to make SSL certificate for local development then you can use mkcert tool for that. And there are very simple commands that you have to run in order to generate the certificates. And after getting the certificates, you can run a HTTPS server using any tool that you want.

Editor Ratings:
User Ratings:
Free/Paid: Free

Get 100 GB FREE

Provide details to get this offer