さくらVPS CentOS6.5でSSLをつかってみる
さくらサーバでSSLつかってみましょう。環境は下記になります。
・FreeBSD 9.1-RELEASE-p7 amd64 ・さくらのレンタルサーバ スタンダード ・Apache/2.2.25
あら独自SSLを使えるのは、ビジネスプロ以降らしい。http://www.sakura.ne.jp/ では、VPSを使ってやってみよう。環境は下記になります。
・CentOS release 6.5 (Final) ・Apache/2.2.15 (Unix) ・OpenSSL 1.0.1e-fips 11 Feb 2013
mod_sslをインストールする
$ yum -y install mod_sslmod_ssl.x86_64 1:2.2.15-29.el6.centosというのがインストールされた。
CA用秘密鍵(ca.key)の作成
$ openssl genrsa -des3 -out /etc/httpd/conf/ca.key -rand rand.dat 1024CA用証明書(ca.crt)の作成
$ openssl req -new -x509 -days 365 -key /etc/httpd/conf/ca.key -out /etc/httpd/conf/ca.crtサーバ用秘密鍵(server.key)の作成
$ openssl genrsa -des3 -out /etc/httpd/conf/server.key -rand rand.dat 1024署名要求書(server.csr)の作成
$ openssl req -new -key /etc/httpd/conf/server.key -out /etc/httpd/conf/server.csrサーバ用秘密鍵(server.key)からのパスフレーズ削除
オリジナルをバックアップしてから、server.keyからのパスフレーズ削除
$ cp /etc/httpd/conf/server.key /etc/httpd/conf/server.key.bak$ openssl rsa -in /etc/httpd/conf/server.key.bak -out /etc/httpd/conf/server.keyサーバ用証明書(server.crt)の作成
$ openssl x509 -req -signkey /etc/httpd/conf/server.key -days 3650 -in /etc/httpd/conf/server.csr -out /etc/httpd/conf/server.crtssl設定ファイル(ssl.conf)の変更
$ vim /etc/httpd/conf.d/ssl.conf
100 # Server Certificate:101 # Point SSLCertificateFile at a PEM encoded certificate. If102 # the certificate is encrypted, then you will be prompted for a103 # pass phrase. Note that a kill -HUP will prompt again. A new104 # certificate can be generated using the genkey(1) command.105106 #SSLCertificateFile /etc/pki/tls/certs/localhost.crt107 SSLCertificateFile /etc/httpd/conf/server.crt #<--これに変更108109 # Server Private Key:110 # If the key is not combined with the certificate, use this111 # directive to point at the key file. Keep in mind that if112 # you've both a RSA and a DSA private key you can configure113 # both in parallel (to also allow the use of DSA ciphers, etc.)114115 #SSLCertificateKeyFile /etc/pki/tls/private/localhost.key116 SSLCertificateKeyFile /etc/httpd/conf/server.key #<--これに変更Apache再起動
/etc/rc.d/init.d/httpd restartこれでhttpsでアクセスすると反映されてた。