Getting StartedSSL Certificates
SSL Certificates for Local Development
To create a localhost.crt
and localhost.key
in the current directory, follow these steps:
Generating SSL Certificates for Local Development
Prerequisites
Ensure you have OpenSSL installed on your system. OpenSSL is typically pre-installed on macOS or Linux. You can verify the installation by running:
bash
openssl version
If not installed, follow the instructions for your operating system to install OpenSSL.
Step-by-Step Guide
- Navigate to the desired directory:
Open your terminal and navigate to the directory where you want to create the SSL certificates:bashcd /path/to/your/directory
- Generate a private key:
Run the following command to generate a private key namedlocalhost.key
:bashopenssl genrsa -out localhost.key 2048
- Create a certificate signing request (CSR):
Use the private key to create a CSR. This step will prompt you to enter information about your organization. You can leave most fields blank, but ensure theCommon Name (CN)
is set tolocalhost
:bashopenssl req -new -key localhost.key -out localhost.csr
- Generate the SSL certificate:
Create a self-signed SSL certificate namedlocalhost.crt
using the CSR and the private key. The certificate will be valid for 365 days:bashopenssl x509 -req -days 365 -in localhost.csr -signkey localhost.key -out localhost.crt
- Clean up:
You can remove the CSR file as it is no longer needed:bashrm localhost.csr
Summary of Commands
bash
cd /path/to/your/directory
openssl genrsa -out localhost.key 2048
openssl req -new -key localhost.key -out localhost.csr
openssl x509 -req -days 365 -in localhost.csr -signkey localhost.key -out localhost.crt
rm localhost.csr
Using the Certificates
You can now use localhost.crt
and localhost.key
to serve your development environment over HTTPS.