phil has a blog - Create your own self signed certificate and enable SSL (Mac OS X Leopard)

Create your own self signed certificate and enable SSL (Mac OS X Leopard)

1. Switch to root

sudo su

2. Make directory

mkdir /etc/apache2/ssl

3. Create certificate

RANDFILE=/dev/random openssl req $@ -new -x509 -days 365 -nodes \
-out /etc/apache2/ssl/apache.pem \
-keyout /etc/apache2/ssl/apache.pem

Common Name (eg, YOUR name) []: localhost

4. Forget httpd-ssl.conf and make httpd-ssl-custom.conf

nano /private/etc/apache2/extra/httpd-ssl-custom.conf

and paste

Listen 443
NameVirtualHost *:443

<VirtualHost localhost:443>

DocumentRoot /Library/WebServer/Documents
ServerName localhost:443

SSLEngine On
SSLCertificateFile /private/etc/apache2/ssl/apache.pem

</VirtualHost>

5. At to the bottom of httpd.conf Include /private/etc/apache2/extra/httpd-ssl-custom.conf

echo "Include /private/etc/apache2/extra/httpd-ssl-custom.conf" >> /etc/apache2/httpd.conf

6. Restart Apache

sudo apachectl restart

If you go to the domain with https:// in Firefox you should be told “The certificate is not trusted because it is self signed.”, then add an exception to allow it.