79529024

Date: 2025-03-23 13:41:18
Score: 0.5
Natty:
Report link

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:

4. Restart Live Server

5. Test in Browser

6. Alternative: Use localhost Instead of 127.0.0.1

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @alt_names
  • Low reputation (1):
Posted by: Deepak Joura 0759