First create a Certs folder in any Drive other than C:/
Install OpenSSL if you don’t have it (it’s available for Windows, macOS, and Linux)
Create a configuration file for OpenSSL to include the SAN. Create a file named san.cnf with the following content:
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
CN = localhost
[v3_req]
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
IP.1 = 127.0.0.1
Run the following OpenSSL command to generate a new key and certificate:
openssl req -x509 -newkey rsa:2048 -nodes -days 365 -keyout localhost.key -out localhost.pem -config san.cnf
In VS code editsettings.json paste this
"liveServer.settings.https": {
"enable": true,
"cert": "D:/Certs/localhost.pem",
"key": "D:/Certs/localhost.key",
"passphrase": ""
}
3. Trust the Certificate
Since this is a self-signed certificate, you need to tell your browser to trust it:
On Windows:
Double-click localhost.pem to open it in the Certificate Viewer.
Click "Install Certificate" and choose to install it in the "Trusted Root Certification Authorities" store.
Restart your browser.
On macOS:
Open Keychain Access.
Drag localhost.pem into the "System" keychain.
Double-click the certificate, expand "Trust," and set "When using this certificate" to "Always Trust."
Restart your browser.
On Linux:
Add the certificate to your system’s trusted certificates (this varies by distribution; for Ubuntu, you might use update-ca-certificates).
Restart your browser.
In Visual Studio Code, stop the Live Server (if it’s running).
Restart it by opening your project and clicking "Go Live" again. The server should now use the updated certificate.
Open https://127.0.0.1:5500 (or the port Live Server is using) in your browser.
If the certificate is correctly configured and trusted, you should no longer see the "Your connection is not private" error.