Apache を 2.0 系列から 2.2 系列へ移行した。デフォルトの http.conf が機能別に分割されて、SSL 関連は httpd-ssl.conf で設定されるようになっている。以前の形式でも一部を修正すれば動くのだが、今後のメンテナンスを考慮して、新しい分割された記述に合わせるようにした。
デフォルトの http.conf では SSL 関連の設定を行う httpd-ssl.conf がコメントアウトされているので、コメントを外して有効にする。
# Secure (SSL/TLS) connections Include etc/httpd/httpd-ssl.conf
http-ssl.conf で、サーバ証明書を SSLCertificate に、鍵を SSLCeritificateKeyFile に設定する。証明書の認証局が中間認証局であったりオレオレ認証局である場合には、認証局の証明書を SSLCertificateChainFile に設定する。
(略) # Server Certificate: # Point SSLCertificateFile at a PEM encoded certificate. If # the certificate is encrypted, then you will be prompted for a # pass phrase. Note that a kill -HUP will prompt again. Keep # in mind that if you have both an RSA and a DSA certificate you # can configure both in parallel (to also allow the use of DSA # ciphers, etc.) SSLCertificateFile "/usr/pkg/etc/httpd/server.crt" #SSLCertificateFile "/usr/pkg/etc/httpd/server-dsa.crt" # Server Private Key: # If the key is not combined with the certificate, use this # directive to point at the key file. Keep in mind that if # you've both a RSA and a DSA private key you can configure # both in parallel (to also allow the use of DSA ciphers, etc.) SSLCertificateKeyFile "/usr/pkg/etc/httpd/server.key" #SSLCertificateKeyFile "/usr/pkg/etc/httpd/server-dsa.key" # Server Certificate Chain: # Point SSLCertificateChainFile at a file containing the # concatenation of PEM encoded CA certificates which form the # certificate chain for the server certificate. Alternatively # the referenced file can be the same as SSLCertificateFile # when the CA certificates are directly appended to the server # certificate for convinience. SSLCertificateChainFile "/usr/pkg/etc/httpd/server-ca.crt" (略)
設定が終わったら普通に再起動すると SSL が有効になる。以前と異なり startssl というものはない。
今回行った SSL 設定のディレクティブのまとめ。紛らわしいものに SSLCACertificateFile というものがある。こちらはクライアント認証を行うときに設定するもの。誤解して設定しても動くところがまた紛らわしい。
- SSLCertificateFile
- サーバ証明書のファイル名。
- SSLCertificateKeyFile
- サーバ秘密鍵のファイル名。
- SSLCertificateChainFile
- サーバ証明書を発行した中間認証局 (CA) の証明書のファイル名。
- SSLCACertificateFile
- クライアント認証を行う場合の、クライアント証明書を発行した CA の証明書のファイル名。誤解を恐れずにいえば、ブラウザにインストールされているルート証明書のようなもの。サーバ証明書を発行した中間認証局の証明書をここに置いても機能するが、中間証明書は SSLCertificateChainFile に置くのが正しい。Web で見られる事例も混同しているのが多いようだ。歴史的な経緯によるのかな?