Enabling SSL Connections for Apache Virtual Hosts on OS X 10.5

2009 February 26
tags: Apache · OS X
by Paul Marcotte

Today, I was able to get https working for localhost connections after following these step by step instructions for creating and signing a cert and updating httpd.conf and httpd-ssl.conf on Mac OS X Hints. Problem is, I need https for vhosts. When trying to connect to a local vhost over https, I encountered the following error: Error code: ssl_error_rx_record_too_long). Much more googling turned up the answer. You need to turn the SSLEngine On for vhosts. Thanks to the Ubuntu forums for that gem. Here's an example vhost that uses SSL.

<VirtualHost 127.0.0.1:443>
DocumentRoot "/Users/paul/Sites/myproject"
ServerName myproject.fancybread.local
SSLEngine On
SSLCertificateFile "/Users/paul/certs/localhost/newcert.pem"
SSLCertificateKeyFile "/Users/paul/certs/localhost/localhost.nopass.key"

DirectoryIndex index.cfm
<Directory "/Users/paul/Sites/myproject">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>