Skip to content

Generate a self-signed openssl certificate valid for localhost, IP v4 127.0.0.1, and IP v6 ::1.

Notifications You must be signed in to change notification settings

NeverOddOrEven/self-signed-ssl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create a self-signed certificate

I frequently have to google instructions for how to generate SSL certs. Therefore, I created this repository to remove one more obstacle to properly securing endpoints.

This configuration generates a certificate valid for localhost, IP v4 127.0.0.1, and IP v6 ::1.

Usage

From your shell:

./generate.sh

Commands

Create a self-signed localhost certificate

mkdir -p output
openssl req -config cert.config -new -x509 \
    -sha256 -newkey rsa:2048 -nodes \
    -keyout output/localhost.key.pem -days 365 \
    -out output/localhost.cert.pem

Show the certificate details

openssl x509 -in output/localhost.cert.pem -text -noout

Create a signing request

openssl req -config cert.config -new -sha256 -newkey rsa:2048 -nodes \
    -keyout output/localhost.key.pem -days 365 -out output/localhost.req.pem

Testing

Start a simple NodeJs server and call with curl, passing the self-signed cert to validate HTTPS.

./test.sh

Credit

Go to the original Stack Overflow question.

About

Generate a self-signed openssl certificate valid for localhost, IP v4 127.0.0.1, and IP v6 ::1.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published