Apache - SSL/TLS(Ben-SSL)
BenSSLパッチを用いたSSLサイトの構築について解説します。
今回はSSLモジュール及び基本モジュールをDSOとして組み込みます。
SSL鍵の配置ディレクトリは、/usr/local/etc/openssl、
そして
OpenSSLを/usr/localへインストールしておきます。
用意するもの
apache_1.3.37.tar.gz
公式サイト
ダウンロードサイト
apache_1.3.37+ssl_1.57.tar.gz
公式サイト
ダウンロードサイト
コンパイル&インストール
% tar zxvf apache_1.3.37.tar.gz
% cp apache_1.3.37+ssl_1.57.tar.gz apache_1.3.37
% cd apache_1.3.37
% tar zxvf apache_1.3.37+ssl_1.57.tar.gz
% env PREFIX=/usr/local ./FixPatch
% ./configure --enable-module=most --enable-shared=max --enable-shared=apache_ssl --with-port=80
% make
% su
# make install
# cp src/modules/ssl/libssl.so /usr/local/apache/libexec/apache_ssl.so
コンフィグレーション
# vi /usr/local/apache/conf/mime.conf
--- /usr/local/apache/conf/mime.types.default Sun Nov 3 18:40:19 2002
+++ /usr/local/apache/conf/mime.types Sun Nov 3 18:47:05 2002
@@ -9,6 +9,7 @@
# registry is at <ftp://ftp.iana.org/in-notes/iana/assignments/media-types/>.
# MIME type Extension
+application/x-x509-ca-cert der
application/EDI-Consent
application/EDI-X12
application/EDIFACT
# vi /usr/local/apache/conf/httpsd.conf
--- httpsd.conf.default Sun Nov 3 19:18:01 2002
+++ httpsd.conf Sun Nov 3 19:20:07 2002
@@ -343,7 +343,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
@@ -1048,3 +1048,29 @@
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
+
+Listen 80
+Listen 443
+
+SSLDisable
+SSLNoCAList
+SSLRandomFile file /dev/urandom 1024
+SSLRandomFilePerConnection file /dev/urandom 1024
+SSLSessionCacheTimeout 15
+SSLCertificateFile /usr/local/etc/openssl/myhost.pem
+SSLCertificateKeyFile /usr/local/etc/openssl/myhost.key
+SSLSessionCacheTimeout 15
+SSLFakeBasicAuth
+SSLBanCipher NULL-MD5:NULL-SHA
+SSLVerifyClient 0
+SSLVerifyDepth 10
+SSLCacheServerPath /usr/local/apache/bin/gcache
+SSLCacheServerPort logs/gcache_port
+
+<VirtualHost _default_:443>
+ DocumentRoot "/usr/local/apache/htdocs"
+ ServerName www.example.com
+ ServerAdmin webmaster@example.com
+ SSLEnable
+ SSLRequireSSL
+</VirtualHost>
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/httpsdctl start
動作確認
http://www.example.com/myhost.der へアクセスし、DERファイルを「開く」でインストールした後に
https://www.example.com/ へのアクセスを確認して終了です。