CentOS5のSSL自己署名についてまとめておく
移転しました。
Apacheはインストール済みとして話を進める。
# yum -y install mod_ssl # cd /etc/pki/tls/certs/
秘密鍵作成
# make server.key ← サーバー用秘密鍵作成 hoge hoge # openssl rsa -in server.key -out server.key ← サーバー用秘密鍵からパスワード削除 hoge ※サーバー用秘密鍵からパスワードを削除するのは、Webサーバー起動時にパスワードを要求されないようにするため
公開鍵作成
# make server.csr ----- umask 77 ; \ /usr/bin/openssl req -utf8 -new -key server.key -out server.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [GB]:JP State or Province Name (full name) [Berkshire]:Tokyo Locality Name (eg, city) [Newbury]:Shinjuku Organization Name (eg, company) [My Company Ltd]:zeal Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) []:zeal.com Email Address []:webmaster@zeal.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: ← 空 An optional company name []: ← 空 -----
サーバー用証明書作成
# openssl x509 -in server.csr -out server.pem -req -signkey server.key -days 365 # chmod 400 server.* # vi /etc/httpd/conf.d/ssl.conf ← ApacheSSL設定ファイル編集 ----- SSLCertificateFile /etc/pki/tls/certs/server.pem ← サーバー用証明書を指定※CentOS5の場合 SSLCertificateKeyFile /etc/pki/tls/certs/server.key ← サーバー用秘密鍵を指定※CentOS5の場合 # General setup for the virtual host, inherited from global configuration #DocumentRoot "/var/www/html" ← #を削除(コメント解除) ↓ DocumentRoot "/var/www/html" -----
Apache 再起動
# /etc/rc.d/init.d/httpd restart