Apache+SSLの設定メモ
httpd.confはまあいいだろうから、SSLのメモを主に。
Apache2.2.4だとデフォルトでSSLが導入されているので、別途入れる必要はなし。
SSLを有効にするにはhttpd.confの中で、SSLに関するあたりをコメントアウトしてやればよい(一番下の方にあったはず)。あと、mod_sslのモジュールをロードするのも忘れずに。多分デフォルトでロードされるようになってると思うけど。
LoadModule ssl_module libexec/apache22/mod_ssl.so ... ... # Secure (SSL/TLS) connections #Include etc/apache22/extra/httpd-ssl.conf ←ここをコメントアウト
それからhttpd-ssl.confを編集。主にサーバ名とアドレスのあたりを変更すればOK。
# General setup for the virtual host DocumentRoot "/usr/local/www/apache22/data" ServerName サーバ名 ServerAdmin メールアドレス ErrorLog /var/log/httpd-error.log TransferLog /var/log/httpd-access.log
次に、サーバ用秘密鍵(server.key)を作成する。
ランダムに秘密鍵を作る。
% sudo openssl genrsa -des3 -out server.key -rand rand.dat 1024
サーバ用公開鍵(server.csr)を作成。
% sudo openssl req -new -key server.key -out server.csr Enter pass phrase for server.key: パスワードを入力 Country Name (2 letter code) [AU]:JP ... Common Name (eg, YOUR name) []: サーバ名を入力 ... An optional company name []:
パスワード入力を無効にする。これをやるとapache起動時にパスワードを聞かれなくなる。
% sudo openssl rsa -in server.key -out server.key
サーバ用証明書(server.crt)を作成。
% sudo openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 365