I'm trying to setup SSL for Apache (installed via XAMPP) on Mac OS X Yosemite.
Let's assume that I have a local hostname called 'my-local-host' already setup. I followed the instructions here to setup the certs running the following commands:
# 1. Create host key
sudo ssh-keygen -f my-local-host.key
# 2. Create SSL certificate
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout my-local-host.key -out my-local-host.crt
# 3. Create nopass Host Key
sudo openssl rsa -in my-local-host.key -out my-local-host.nopass.key
Note: I did all this inside the /Applications/XAMPP/xamppfiles/apache2/ssl
directory.
After this, I added a virtual host listing to httpd-vhosts.conf
.
<VirtualHost *:443>
ServerName my-local-host
DocumentRoot "/path/to/my-local-host/files"
SSLEngine on
SSLCertificateFile "/Applications/XAMPP/xamppfiles/apache2/ssl/my-local-host.crt"
SSLCertificateKeyFile "/Applications/XAMPP/xamppfiles/apache2/ssl/my-local-host.key"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/Applications/XAMPP/xamppfiles/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
<Directory "/path/to/my-local-host/files">
ServerSignature Off
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/my_local_host_log"
</VirtualHost>
I then added the certificate to system Keychain with the following:
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /Applications/XAMPP/xamppfiles/apache2/ssl/my-local-host.crt
And then I restarted Apache and attempted to load https://my-local-host in the Chrome browser. Here's the error I received:
This server could not prove that it is my-local-host; its security certificate is from [missing_subjectAltName].
After searching online it appears that this is an issue relating to Chrome dropping CommonName support from Chrome 58.
I found this aptly title post: Missing [missing_subjectAltName] in ssl certificate (since Chrome 58) that sported a command for creating a compliant certificate:
sudo openssl req -newkey rsa:2048 -x509 -nodes -keyout my-local-host.key -new -out my-local-host.crt -subj /CN=my-local-host -reqexts SAN -extensions SAN -config <(cat /System/Library/OpenSSL/openssl.cnf ; printf '[SAN]\nsubjectAltName=DNS:my-local-host') -sha256 -days 3650
Unfortunately, when I run this I get the following error:
error on line -1 of /dev/fd/63
80231:error:02001009:system library:fopen:Bad file descriptor:/SourceCache/OpenSSL098/OpenSSL098-52.40.1/src/crypto/bio/bss_file.c:126:fopen('/dev/fd/63','rb')
80231:error:2006D002:BIO routines:BIO_new_file:system lib:/SourceCache/OpenSSL098/OpenSSL098-52.40.1/src/crypto/bio/bss_file.c:131:
80231:error:0E078002:configuration file routines:DEF_LOAD:system lib:/SourceCache/OpenSSL098/OpenSSL098-52.40.1/src/crypto/conf/conf_def.c:199:
Is there some other, less cumbersome way I can create a compliant certificate that addresses the issue with missing_subjectAltName
on Chrome?