Reference - https://medium.freecodecamp.org/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec
- Create rootCA.key file by following command.
- You need to specify the password. (Record it somewhere, you'll need it later)
openssl genrsa -des3 -out rootCA.key 2048
- You'll need to enter the password specified for rootCA.key.
- In Distinguished fields, set the Organization Name to identify the certificate later. (We'll set it XYZ now)
- You can also skip the fields.
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
- Go to Settings -> Advanced -> Manage certificates -> [信頼されたルート証明機関] -> Import -> Select the rootCA.pem and complete the wizard
- You'll find the XYZ after imported.
- Run command below to create server.csr and server.key files.
- In Distinguished fields, set the Organization Name to identify the certificate later. (We'll set it ABC now)
- Note that, you can also skip the fields.
- You can also left out the challenge password
openssl req -new -sha256 -nodes -out server.csr -newkey rsa:2048 -keyout server.key
- Create v3.ext file and add below content
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
- And run the following command to create server.crt file.
- You'll need to enter the password specified for rootCA.key.
openssl x509 -req -in server.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.crt -days 500 -sha256 -extfile v3.ext
Go to xampp\apache\conf and replace the
- ssl.crt/server.crt
- ssl.csr/server.csr
- ssl.key/server.key
files with the one we have just created.
Restart the apache server in xampp.
After that go to https://localhost and you'll see your localhost SSL certificate is valid now.
Note it takes some time. I find it working after reloading the page, restarting the chrome or sometimes restarting PC