apache2 + ssl

% sudo port install apache2

server.keyの作成

% cd /opt/local/apache2/conf
% sudo openssl genrsa -des3 -rand /var/log/system.log -out server.key 1024

server.csrの作成

Common Name(CN)には、apacheを起動するホストのFQDNを設定すること

% sudo openssl req -new -key server.key -out server.csr

Country Name (2 letter code) [AU]:JP
State or Province Name (full name) [Some-State]:My Prefecture
Locality Name (eg, city) :My City
Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Company
Organizational Unit Name (eg, section)
:My Department
Common Name (eg, YOUR name) :my.domain
Email Address
:oppara@example.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:

server.crtの作成

% sudo openssl x509 -req -in server.csr -signkey server.key -out server.crt -days 3560

httpd-ssl.confの修正

% sudo vi /opt/local/apache2/conf/extra/httpd-ssl.conf

#ServerName www.example.com:443
ServerName my.domain:443

httpd.confの修正

% sudo vi /opt/local/apache2/conf/httpd.conf

#Include conf/extra/httpd-ssl.conf
Include conf/extra/httpd-ssl.conf

apache2の再起動

% sudo /opt/local/apache2/bin/apachectl configtest
% sudo /opt/local/apache2/bin/apachectl stop
% sudo /opt/local/apache2/bin/apachectl start

apache2起動時のパスフレーズ確認をしないようにする

% sudo mv server.key server.key.orig
% sudo openssl rsa -in server.key.orig -out server.key
% sudo chmod 400 server.key

OS起動時にapache2を起動させる

sudo launchctl load -w /opt/local/etc/LaunchDaemons/org.macports.apache2/org.macports.apache2.plist