I have created a self-signed SSL certificate for the localhost CN. Firefox accepts this certificate after initially complaining about it, as expected. Chrome and IE, however, refuse to accept it, even after adding the certificate to the system certificate store under Trusted Roots. Even though the certificate is listed as correctly installed when I click "View certificate information" in Chrome's HTTPS popup, it still insists the certificate cannot be trusted.
What am I supposed to do to get Chrome to accept the certificate and stop complaining about it?
Navigate to the site with the cert you want to trust, and click through the usual warnings for untrusted certificates. In the address bar, right click on the red warning triangle and "Not secure" message and, from the resulting menu, select "Certificate" to show the certificate.
1) Open Google Chrome browser. 2) Type chrome://flags/#allow-insecure-localhost in address bar. 3) Click on Enable. 4) Select "Relaunch Now" option displaying at the bottom after making the changes OR Re-open the chrome browser.
Use Chrome's Preferences -> Under The Hood -> Manage Certificates -> Import. On the "Certificate Store" screen of the import, choose "Place all certificates in the following store" and browse for "Trusted Root Certification Authorities." Restart Chrome.
localhost
onlySimply paste this in your chrome:
chrome://flags/#allow-insecure-localhost
You should see highlighted text saying:
Allow invalid certificates for resources loaded from localhost
Click Enable.
Try typing thisisunsafe
anywhere on the window, and the browser should let you visit the page.
-OR-
For a local self-signed cert that avoids arcane commands, specialized knowledge, and manual steps try mkcert
from this answer.
This worked for me:
Chrome Settings > Show advanced settings > HTTPS/SSL > Manage Certificates
.Authorities
tab and scroll down to find your certificate under the Organization Name that you gave to the certificate.You should get the nice green lock on your pages now.
EDIT: I tried this again on a new machine and the certificate did not appear on the Manage Certificates window just by continuing from the red untrusted certificate page. I had to do the following:
https://
is crossed out in red), click the lock > Certificate Information. NOTE: on newer versions of chrome, you have to open Developer Tools > Security
, and select View certificate
.Details tab > Export
. Choose PKCS #7, single certificate
as the file format.Authorities tab > Import
and choose the file to which you exported the certificate, and make sure to choose PKCS #7, single certificate
as the file type.openssl
commands, you can accomplish this.(Please don't change your browser security settings.)
With the following code, you can (1) become your own CA, (2) then sign your SSL certificate as a CA. (3) Then import the CA certificate (not the SSL certificate, which goes onto your server) into Chrome/Chromium. (Yes, this works even on Linux.)
NB: For Windows, some reports say that openssl
must be run with winpty
to avoid a crash.
######################
# Become a Certificate Authority
######################
# Generate private key
openssl genrsa -des3 -out myCA.key 2048
# Generate root certificate
openssl req -x509 -new -nodes -key myCA.key -sha256 -days 825 -out myCA.pem
######################
# Create CA-signed certs
######################
NAME=mydomain.example # Use your own domain name
# Generate a private key
openssl genrsa -out $NAME.key 2048
# Create a certificate-signing request
openssl req -new -key $NAME.key -out $NAME.csr
# Create a config file for the extensions
>$NAME.ext cat <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = $NAME # Be sure to include the domain name here because Common Name is not so commonly honoured by itself
DNS.2 = bar.$NAME # Optionally, add additional domains (I've added a subdomain here)
IP.1 = 192.168.0.13 # Optionally, add an IP address (if the connection which you have planned requires it)
EOF
# Create the signed certificate
openssl x509 -req -in $NAME.csr -CA myCA.pem -CAkey myCA.key -CAcreateserial \
-out $NAME.crt -days 825 -sha256 -extfile $NAME.ext
To recap:
myCA.pem
as an "Authority" (not into "Your Certificates") in your Chrome settings (Settings > Manage certificates > Authorities > Import)$NAME.crt
and $NAME.key
files in your serverExtra steps (for Mac, at least):
extendedKeyUsage=serverAuth,clientAuth
below basicConstraints=CA:FALSE
, and make sure you set the "CommonName" to the same as $NAME
when it's asking for setupYou can check your work to ensure that the certificate is built correctly:
openssl verify -CAfile myCA.pem -verify_hostname bar.mydomain.example mydomain.example.crt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With