Kevin Warrington

Loading clever subtitle...

SSL Certificate for Localhost

Create a self-signed certificate and move it to the apache conf directory.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# generate private key
openssl genrsa -des3 -out server.key 1024

# generate csr
openssl req -new -key server.key -out server.csr

# remove passphrase from private key
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key

# create self-signed cert 
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

# move to apache conf dir
cp server.crt /etc/apache2/server.crt
cp server.key /etc/apache2/server.key

Enable the default ssl configuration, /etc/apache2/httpd.conf

1
2
# uncomment the following line
Include /private/etc/apache2/extra/httpd-ssl.conf

Add host entry for development site, /etc/hosts

1
127.0.0.1 devsite.local

Modify the default virtual host entry, /etc/apache2/extra/httpd-ssl.conf

1
2
3
# update config for site
DocumentRoot "/Library/WebServer/Documents/devsite"
ServerName devsite.local:433

Restart Apache

1
sudo apachectl restart

(Optional) - Add as trusted certificate

1
2
3
4
open /etc/apache2/server.crt

# Always trust for all users
# Always trust when using the certificate

Restart Chrome

Comments