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?
On the Mac, you can use the Keychain Access utility to add the self-signed certificate to the System keychain, and Chrome will then accept it. I found the step-by-step instructions here:
Google Chrome, Mac OS X and Self-Signed SSL Certificates
Basically:
UPDATE FOR CHROME 58+ (RELEASED 2017-04-19)
As of Chrome 58, identifying the host using only
commonName
is being removed. See further discussion here and bug tracker here. In the past,subjectAltName
was used only for multi-host certs so some internal CA tools may not include them.If your self-signed certs worked fine in the past but suddenly started generating errors in Chrome 58, this is why.
So whatever method you are using to generate your self-signed cert (or cert signed by a self-signed CA), ensure that the server's cert contains a
subjectAltName
with the properDNS
and/orIP
entry/entries, even if it's just for a single host.For openssl, this means your OpenSSL config (
/etc/ssl/openssl.cnf
on Ubuntu) should have something similar to the following for a single host:or for multiple hosts:
In Chrome's cert viewer (which has moved to "Security" tab under F12) you should see it listed under
Extensions
asCertificate Subject Alternative Name
:UPDATED Apr 3/2018
Recommended by the Chromium Team
https://www.chromium.org/Home/chromium-security/deprecating-powerful-features-on-insecure-origins#TOC-Testing-Powerful-Features
Quick Super-Easy Solution
There is a secret bypass phrase that can be typed into the error page to have Chrome proceed despite the security error: thisisunsafe (in earlier versions of Chrome, type badidea, and even earlier, danger). DO NOT USE THIS UNLESS YOU UNDERSTAND EXACTLY WHY YOU NEED IT!
Source:
https://chromium.googlesource.com/chromium/src/+/d8fc089b62cd4f8d907acff6fb3f5ff58f168697%5E%21/
(NOTE that
window.atob('dGhpc2lzdW5zYWZl')
resolves tothisisunsafe
)The latest version of the source is @ https://chromium.googlesource.com/chromium/src/+/refs/heads/master/components/security_interstitials/core/browser/resources/interstitial_large.js and the
window.atob
function can be executed in a JS console.For background about why the Chrome team changed the bypass phrase (the first time):
https://bugs.chromium.org/p/chromium/issues/detail?id=581189
If all else fails
For quick one-offs if the "Proceed Anyway" option is not available, nor the bypass phrase is working, this hack works well:
Allow certificate errors from
localhost
by enabling this flag (note Chrome needs a restart after changing the flag value):chrome://flags/#allow-insecure-localhost
(and vote-up answer https://stackoverflow.com/a/31900210/430128 by @Chris)
If the site you want to connect to is
localhost
, you're done. Otherwise, setup a TCP tunnel to listen on port 8090 locally and connect tobroken-remote-site.com
on port 443, ensure you havesocat
installed and run something like this in a terminal window:socat tcp-listen:8090,reuseaddr,fork tcp:broken-remote-site.com:443
Go to https://localhost:8090 in your browser.
This post is already flooded with responses, but I created a bash script based on some of the other answers to make it easier to generate a self-signed TLS certificate valid in Chrome (Tested in
Chrome 65.x
). Hope it's useful to others.After you install (and trust) the certificate, don't forget to restart Chrome (
chrome://restart
)Another tool worth checking out is CloudFlare's
cfssl
toolkit:This worked for me. See: http://www.robpeck.com/2010/10/google-chrome-mac-os-x-and-self-signed-ssl-certificates/#.Vcy8_ZNVhBc
In the address bar, click the little lock with the X. This will bring up a small information screen. Click the button that says "Certificate Information."
Click and drag the image to your desktop. It looks like a little certificate.
Double-click it. This will bring up the Keychain Access utility. Enter your password to unlock it.
Be sure you add the certificate to the System keychain, not the login keychain. Click "Always Trust," even though this doesn't seem to do anything.
After it has been added, double-click it. You may have to authenticate again.
Expand the "Trust" section.
"When using this certificate," set to "Always Trust"