Apache - SSL/TLS(mod_ssl)
- はじめに
- mod_sslモジュールを用いたSSLサイトの構築について解説します。
今回は基本モジュール&SSLモジュールをDSOとして組み、
SSL鍵は、/usr/local/etc/openssl 以下へ配置します。
なお、予めOpenSSL を/usr/localへインストールしておきます。
- 用意するもの
- apache_1.3.41.tar.gz
- mod_ssl-2.8.31-1.3.41.tar.gz
- mm-1.4.2.tar.gz
- コンパイル&インストール(mm)
% tar zxvf mm-1.4.2.tar.gz
% cd mm-1.4.2
% ./configure
% make
% su
# make install
- コンパイル&インストール(apache)
% tar zxvf apache_1.3.41.tar.gz
% tar zxvf mod_ssl-2.8.31-1.3.41.tar.gz
% cd mod_ssl-2.8.31-1.3.41
% ./configure --with-apache=../apache_1.3.41 --with-ssl=/usr/local --with-mm=/usr/local --enable-module=most --enable-shared=max --enable-shared=ssl --with-port=80
% cd ../apache_1.3.41
% make
% su
# make install
- コンフィグレーション
# vi /usr/local/apache/conf/httpd.conf
--- httpd.conf.default 2003-11-03 00:40:15.929901000 +0900
+++ httpd.conf 2003-11-03 12:19:16.015348000 +0900
@@ -360,7 +360,7 @@
# machine always knows itself by this address. If you use Apache strictly for
# local testing and development, you may use 127.0.0.1 as the server name.
#
-#ServerName www.example.com
+ServerName www.example.com
#
# DocumentRoot: The directory out of which you will serve your
@@ -1044,7 +1044,7 @@
# Some MIME-types for downloading Certificates and CRLs
#
<IfDefine SSL>
-AddType application/x-x509-ca-cert .crt
+AddType application/x-x509-ca-cert .crt .der
AddType application/x-pkcs7-crl .crl
</IfDefine>
@@ -1131,16 +1131,14 @@
# built time. Keep in mind that if you've both a RSA and a DSA
# certificate you can configure both in parallel (to also allow
# the use of DSA ciphers, etc.)
-SSLCertificateFile /usr/local/etc/ssl.crt/server.crt
-#SSLCertificateFile /usr/local/etc/ssl.crt/server-dsa.crt
+SSLCertificateFile /usr/local/etc/openssl/myhost.pem
# 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/local/etc/ssl.key/server.key
-#SSLCertificateKeyFile /usr/local/etc/ssl.key/server-dsa.key
+SSLCertificateKeyFile /usr/local/etc/openssl/myhost.key
# Server Certificate Chain:
# Point SSLCertificateChainFile at a file containing the
- SSL鍵の作成
# mkdir -p /usr/local/etc/openssl
# cd /usr/local/etc/openssl
# openssl req -new -x509 -nodes -days 7300 -out myhost.pem -keyout myhost.key
# chmod 600 myhost.key
# openssl x509 -inform pem -outform der -in myhost.pem -out myhost.der
# cp myhost.der /usr/local/apache/htdocs
- 起動
# /usr/local/apache/bin/apachectl startssl
- 動作確認
http://www.example.com/myhost.der へアクセスします。するとDERファイルのダウンロードが始まりますので、
「開く」を選択してブラウザへインストールして下さい。
そして、 https://www.example.com/ へのアクセスが成功すれば作業終了です。