HTTPS / SMTP over SSL/TLS (SMTPS) / IMAP over SSL/TLS (IMAPS) / POP over SSL/TLS (POPS) を使用するには署名つきSSL証明書が必要だ。利用者が限られたサービスでは自己署名した、いわゆるオレオレ証明書でSSLを実現することも不可能ではないが、ボクは年間10.95ドル(1,115円)でRapidSSLを利用している。
RapidSSLはGeoTrustの最安ブランドで、GeoTrustはSymantec(旧VeriSign)グループのひとつである。メール一通だけの確認なので手軽な一方、信用度はそれほど高くはないが、どこが発行しているかどうかを気にしてSSL通信しているユーザーはほとんどいないので、EV証明書(Webブラウザーのアドレス・バーに所有者名が出るやつ)ほどはいらないのであれば、悪くない選択だろう。
RapidSSLのルート証明書は2010年10月10日以降 GeoTrust Global CA だが、それ以前と同様に Equifax Secure Certificate Authority をルート証明書にするクロス・ルート設定をすることもできる。携帯電話も最近の機種であればこの2つのどちらにも対応しているが、一部のAndroidがなにげに GeoTrust Global CA に対応していないので、Equifax Secure Certificate Authority をルート証明書にしたほうが良いだろう。会社から支給されている DOCOMO LG Optimus chat L-04C は Android 2.2.2 にも関わらず、CACertManで確認したところ GeoTrust Global CA には対応していなかった。Apple iPhone は Apple: iOS 3.x: 信用できるルート証明書の一覧 によると、少なくとも iOS 3 からはどちらの証明書にも対応している。
RapidSSLは直販だと1年契約で49ドル(4988円)だが代理店経由だともっと安く、ボクはNamecheap.comで1年契約10.95ドル(1,115円)で購入した。上部メニューから Security > SSL Certificates を選び、真ん中ら辺から Brand > GeoTrust を選び、RapidSSLを Add to Cart すればよい。
購入が完了したら秘密鍵と署名要求 (CSR) を作成しよう。以下は RapidSSL: Generate CSR for Apache-SSL をベースに Scientific Linux (SL) 6.2 を使用して作成しているが、Red Hat Enterprise Linux (RHEL) / CentOS / Oracle Linux でも同様だろう。
RapidSSL指定の方法や /etc/pki/tls/certs/Makefile を使った方法で秘密鍵を作成すると、鍵を使用するたびにパスワード入力が必要になり、SSLを使用する Apache HTTP Server などを起動するたびにパスワード入力が必要になってしまうため、以下のような方法でパスワードなしの秘密鍵を作成する。2048ビットの鍵が必要なので、2048
を必ずつけよう。
[root@zulu ~]# openssl genrsa 2048 > /etc/pki/tls/private/rewse.jp.2014.key Generating RSA private key, 2048 bit long modulus ..............+++ ...................+++ e is 65537 (0x10001)
つづいてCSR(Certificate Signing Request。証明書署名リクエスト)を作成する。Common Name はSSLでアクセスするときのサーバー名と一致しなければならない。つまり、Webならwww.rewse.jp
、メールならmail.rewse.jp
などだ。rewse.jp
のようにWebもメールも同一マシンで、サブドメインを使用せずにアクセスする場合は、1つの証明書で両方に使える。Email Address / A challenge password / An optional company name は空白のままにしよう。
[root@zulu ~]# openssl req -new -key /etc/pki/tls/private/rewse.jp.2014.key -out /etc/pki/tls/certs/rewse.jp.2014.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) [XX]:JP State or Province Name (full name) []:Tokyo Locality Name (eg, city) [Default City]:Nakano-ku Organization Name (eg, company) [Default Company Ltd]:Rewse Lab. Organizational Unit Name (eg, section) []:[Enter] Common Name (eg, your name or your server's hostname) []:rewse.jp Email Address []:[Enter] Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []:[Enter] An optional company name []:[Enter]
@namecheap.comから Namecheap.com Order Summary というメールが届いているはずなので、そのメールにある SSL listing page から Activate Now をクリックし、Select web server を Apache + OpenSSL にして、Enter csr に先ほど作ったCSRをコピペする。
[root@zulu ~]# cat /etc/pki/tls/certs/rewse.jp.2014.csr -----BEGIN CERTIFICATE REQUEST----- MIICnjCCAYYCAQAwWTELMAkGA1UEBhMCSlAxDjAMBgNVBAgMBVRva3lvMRIwEAYD VQQHDAlOYWthbm8ta3UxEzARBgNVBAoMClJld3NlIExhYi4xETAPBgNVBAMMCHJl ......
承認者のメールアドレスを選択する。ボクの環境ではpostmasterはrootのエイリアスとして指定されているので、こちらを選択した。事前に手元のメーラーから送信して、ちゃんと受信できるか試しておくと良いだろう。
指定したアドレスに@geotrust.comから RapidSSL Certificate Request Confirmation というメールが届く。記載のURLをクリックすると以下のような画面になり、「I Approve」をクリックすると署名つき証明書が発行される。
再び@geotrust.comから Subject: rewse.jp RapidSSL Order: 9999999 Complete というメールが届き、Web Server CERTIFICATE というところに自分のドメイン名の署名つきSSL証明書が載っている。-----BEGIN CERTIFICATE-----
から-----END CERTIFICATE-----
を含めて /etc/pki/tls/certs/rewse.jp.2014.crt にコピペし、有効期限を見てみよう。Validity Not After というのがこの証明書の有効期限だ。
[root@zulu ~]# openssl x509 -text -in /etc/pki/tls/certs/rewse.jp.2014.crt | head Certificate: Data: Version: 3 (0x2) Serial Number: 1226551 (0x12b737) Signature Algorithm: sha1WithRSAEncryption Issuer: C=US, O=GeoTrust, Inc., CN=RapidSSL CA Validity Not Before: May 9 13:38:16 2014 GMT Not After : Jul 11 21:09:03 2015 GMT Subject: serialNumber=2aR8boyjiE0rCg3oYyBxFuOQ5H/tR7lQ, OU=GT29814907, OU=See www.rapidssl.com/resources/cps (c)14, OU=Domain Control Validated - RapidSSL(R), CN=rewse.jp
Apache 2.2 でSSLを設定する方法は RapidSSL: Install certificate in Apache に載っている。Subject: rewse.jp RapidSSL Order: 9999999 Complete メールに載っている INTERMEDIATE CA(中間認証局)は ルート証明書が GeoTrust Global CA だけのもののため、GeoTrust Global CA → RapidSSL CA → rewse.jpというツリーになるが、RapidSSL Intermediate CAs に載っている Bundled CA Version を使うと、Equifax Secure Certificate Authority → GeoTrust Global CA → RapidSSL CA → rewse.jpというツリーになる。先述のとおり、Android対策で Bundled CA Version からコピペして /etc/pki/tls/certs/ca-rapidssl.2014.crt とするのがオススメだ。
ここまでで作成した秘密鍵 / 署名つき証明書 / 中間CA証明書を設定する。
# Server Certificate: # Point SSLCertificateFile at a PEM encoded certificate. If # the certificate is encrypted, then you will be prompted for a # pass phrase. Note that a kill -HUP will prompt again. A new # certificate can be generated using the genkey(1) command. #SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateFile /etc/pki/tls/certs/rewse.jp.2014.crt # 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 /etc/pki/tls/private/localhost.key SSLCertificateKeyFile /etc/pki/tls/private/rewse.jp.2014.key # Server Certificate Chain: # Point SSLCertificateChainFile at a file containing the # concatenation of PEM encoded CA certificates which form the # certificate chain for the server certificate. Alternatively # the referenced file can be the same as SSLCertificateFile # when the CA certificates are directly appended to the server # certificate for convinience. #SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt SSLCertificateChainFile /etc/pki/tls/certs/ca-rapidssl.2014.crt
Apacheを再起動したら、RapidSSL Certificate Installation Checker でSuccessfulが出ることを確認しよう。また、Google Chrome for Mac でURLの左にある鍵アイコンをクリックし、接続 → 証明書情報を選ぶと以下のようなツリーを見ることができる。Internet Explorer / Mozilla Firefox / Google Chrome for Windows / Apple Safari では正しくクロス・ルートに設定していても GeoTrust Global CA がルート証明書に見えてしまうので注意しよう。
Postfix 2.3.3/2.6.6 で SMTP over SSL/TLS (SMTPS) を行う場合は中間CA証明書を含めた署名つき証明書を作成する必要がある。
[root@zulu ~]# cd /etc/pki/tls/certs [root@zulu certs]# cat rewse.jp.2014.crt ca-rapidssl.2014.crt > rewse.jp.withintermediate.2014.crt
smtpd_tls_cert_file = /etc/pki/tls/certs/rewse.jp.withintermediate.2014.crt smtpd_tls_key_file = /etc/pki/tls/private/rewse.jp.2014.key
同様にDovecotで IMAP over SSL/TLS (IMAPS) / POP over SSL/TLS (POPS) を行う場合は、この中間CA証明書を含めた署名つき証明書を指定する。以下は Dovecot 2.0.9 での設定方法だ。<
を忘れずに。
#ssl_cert = </etc/pki/dovecot/certs/dovecot.pem #ssl_key = </etc/pki/dovecot/private/dovecot.pem ssl_cert = </etc/pki/tls/certs/rewse.jp.withintermediate.2014.crt ssl_key = </etc/pki/tls/private/rewse.jp.2014.key
以下は Dovecot 1.0.7 での設定方法だ。こちらは<
が必要ない。
# PEM encoded X.509 SSL/TLS certificate and private key. They're opened before # dropping root privileges, so keep the key file unreadable by anyone but # root. Included doc/mkcert.sh can be used to easily generate self-signed # certificate, just make sure to update the domains in dovecot-openssl.cnf ssl_cert_file = /etc/pki/tls/certs/rewse.jp.withintermediate.2014.crt ssl_key = /etc/pki/tls/private/rewse.jp.2014.key
2012年3月21日 初版公開
2014年5月15日 第2版公開