最近のWebサービスでは、全ユーザに対して常時HTTPS接続を提供するものが増えてきました。
サーバにSSL設定を行うことで、Webサーバとブラウザ間の通信が暗号化され安全な通信を行うことができます。
今回は、LinuxサーバにApacheがインストールされ、HTTP接続ができる状態であるところから説明します。
検証環境
AWS(Amazon Web Service) - EC2
$ cat system-release
Amazon Linux AMI release 2011.02.1.1 (beta)
既にApacheはインストール済みの状態てす。
opensslのバージョン確認
OpenSSL 1.0.1e-fips 11 Feb 2013
Generating RSA private key, 2048 bit long modulus
.........+++
............+++
e is 65537 (0x10001)
Enter pass phrase for server.key:[←パスワード入力]
Verifying - Enter pass phrase for server.key:[←パスワード入力]
Enter pass phrase for server.key:[←パスワード入力]
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) [XX]: [←JP]
State or Province Name (full name) []: [←都道府県 ex. Miyagi]
Locality Name (eg, city) [Default City]: [←市区町村 ex. Sendai]
Organization Name (eg, company) [Default Company Ltd]: [←会社名]
Organizational Unit Name (eg, section) []: [←空でEnter]
Common Name (eg, your name or your server''s hostname) []: [←重要! コモンネーム]
Email Address []: [←メールアドレス ex. xxx@xxx.xx]
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: [←空でEnter]
An optional company name []: [←空でEnter]
-----BEGIN CERTIFICATE REQUEST-----
[略]
-----END CERTIFICATE REQUEST-----
これをコピーしてSSL証明書の購入時に使用します。
今回は、SSLボックスで、RapidSSLを購入しました。
代理店がたくさんあり、どこで購入するか迷うところですが、安くてカード決済ができたのでSSLボックスにしました。
購入画面で、先程のCSRを入力(BEGIN CERTIFICATE REQUEST、END CERTIFICATE REQUESTの行も含む)します。
購入から5分程度で、RapidSSL証明書がメールで送られてきます。早い!
メールで送られてきた証明書をコピー
/etc/pki/tls/certs
-----BEGIN CERTIFICATE-----
[略]
-----END CERTIFICATE-----
Enter pass phrase for server.key:[←パスワード入力]
writing RSA key
[以下の行を追加します]
SSLCertificateFile /etc/pki/tls/certs/server.crt
SSLCertificateKeyFile /etc/pki/tls/certs/server.key
ServerName bringup.csdev.co.jp:443