Generate a localhost SSL Certificate with letsencrypt

Saturday, July 22, 2023

Generate a localhost SSL Certificate with letsencrypt

#letsencrypt #localhost #openssl #security #ssl #ssl-certificate

This article is published at GitHub.You can raise issues, create pull requests or even fork the content...its open source.

In this article, you will learn how to generate a localhost SSL Certificate with letsencrypt.

Prerequisites

The following prerequisites will be required to complete this tutorial:

Generate a localhost SSL Certificate with letsencrypt

  1. Create a folder named certificates.

  2. Add a file named req.cnf into the certificates folder with the following contents. Replace {YourLocation}, and {YourOrganisation} with your own values.

    [req]
    distinguished_name = req_distinguished_name
    x509_extensions = v3_req
    prompt = no
    [req_distinguished_name]
    C = GB
    ST = {YourLocation}
    L = {YourLocation}
    O = {YourOrganisation}
    CN = localhost
    [v3_req]
    keyUsage = critical, digitalSignature, keyAgreement
    extendedKeyUsage = serverAuth
    subjectAltName = @alt_names
    [alt_names]
    DNS.1 = localhost
    
  3. Right click in the certificates folder, and select Git Bash Here.

    GitBash Here

  4. Run the following command to generate an SSL certificate and key in the certificates folder.

    openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout localhost.key -out localhost.key -out localhost.crt -config req.cnf -sha256
    

Got a comment?

All my articles are written and managed as Markdown files on GitHub.

Please add an issue or submit a pull request if something is not right on this article or you have a comment.

If you'd like to simply say "thanks", then please send me a so the rest of Twitter can see how awesome my work is.

An unhandled error has occurred. Reload