Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid self signed SSL cert - "Subject Alternative Name Missing"

Recently, Chrome has stopped working with my self signed SSL certs, and thinks they're insecure. When I look at the cert in the DevTools | Security tab, I can see that it says

Subject Alternative Name Missing The certificate for this site does not contain a Subject Alternative Name extension containing a domain name or IP address.

Certificate Error There are issues with the site's certificate chain (net::ERR_CERT_COMMON_NAME_INVALID).

How can I fix this?

like image 740
Brad Parks Avatar asked Apr 27 '17 18:04

Brad Parks


People also ask

How do you add subject alternative name to certificate using OpenSSL?

If you want your certificates to support Subject Alternative Names (SANs), you must define the alternative names in a configuration file. OpenSSL does not allow you to pass Subject Alternative Names (SANs) through the command line, so you have to add them to a configuration file first.

What is subject alternative name in certificate?

The Subject Alternative Name (SAN) is an extension to the X. 509 specification that allows users to specify additional host names for a single SSL certificate. The use of the SAN extension is standard practice for SSL certificates, and it's on its way to replacing the use of the common name.


1 Answers

To fix this, you need to supply an extra parameter to openssl when you're creating the cert, basically

-sha256 -extfile v3.ext

where v3.ext is a file like so, with %%DOMAIN%% replaced with the same name you use as your Common Name. More info here and over here. Note that typically you'd set the Common Name and %%DOMAIN%% to the domain you're trying to generate a cert for. So if it was www.mysupersite.com, then you'd use that for both.

v3.ext

authorityKeyIdentifier=keyid,issuer basicConstraints=CA:FALSE keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment subjectAltName = @alt_names  [alt_names] DNS.1 = %%DOMAIN%% 

Note: Scripts that address this issue, and create fully trusted ssl certs for use in Chrome, Safari and from Java clients can be found here

Another note: If all you're trying to do is stop chrome from throwing errors when viewing a self signed certificate, you can can tell Chrome to ignore all SSL errors for ALL sites by starting it with a special command line option, as detailed here on SuperUser

like image 100
Brad Parks Avatar answered Sep 28 '22 05:09

Brad Parks