Skip to content
Afa' Afa'

Generate SSL certificat for localhost

Generate a self-signed TLS certificate and key for local development with openssl.

1 min read Updated

A single openssl command that generates a self-signed certificate and key for local development. It creates a 2048-bit RSA key valid for 365 days; adjust the subject fields as needed. The command is below.

generate-ssl-certificat-for-localhost.sh

bash
# Use 'localhost' for the 'Common name'
openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt -subj "/C=FR/ST=Ile-de-France/L=Paris/O=My Org/OU=My Org Unit/CN=example.com"
Something wrong or want to discuss this article? Get in touch

Search articles and projects

Type to filter articles and projects. Use the arrow keys to move through results and Enter to open one. Press Escape to close.