さくらのVPSにRapidSSLを導入する(CentOS6.6+Apache+RapidSSL)
備忘録も兼ねて…ApacheのInstallは割愛します。
CSR作成
秘密鍵作成
# cd /etc/pki/tls/certs/ # openssl genrsa -des3 -out server.key 2048 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: (←パスフレーズを再入力)
CSR作成
※下記は入力例です
# openssl req -new -key server.key -out server.csr 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) :Osaka ←都道府県 Locality Name (eg, city) [Default City]:Osaka-shi ←市区町村 Organization Name (eg, company) [Default Company Ltd]: example.info ←組織名 ※個人運営なのでドメイン名にしています(何でも良い) Organizational Unit Name (eg, section) : ←部署名 Common Name (eg, your name or your server's hostname) :www.example.info ←ドメイン名 Email Address :webmaster@example.info ←メールアドレス Please enter the following 'extra' attributes to be sent with your certificate request A challenge password : ←空Enter An optional company name : ←空Enter
CSRの内容確認
# openssl req -text -noout -in server.csr Certificate Request: Data: Version: 0 (0x0) Subject: C=JP, ST=Osaka, L=Osaka-shi, O=example.info, CN=www.example.info/emailAddress=webmaster@example.info Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: (略) Exponent: 65537 (0x10001) Attributes: (略) Signature Algorithm: sha1WithRSAEncryption (略)
Subject: の行が合っていることと、Public-Key: の行が 2048 bitであることが確認できれば良い
証明書発行申請
# cat server.csr -----BEGIN CERTIFICATE REQUEST----- (略) -----END CERTIFICATE REQUEST-----
で表示される文字列をコピー、ペーストする
証明書ファイルの発行/確認
さくらインターネット社からの案内に従って対応し、証明書を発行。
発行された証明書(server.crt)ファイルをテキストエディタなどで開いてサーバに貼り付ける。
# cd /etc/pki/tls/certs/ # vi server.crt -----BEGIN CERTIFICATE----- (略) -----END CERTIFICATE-----
証明書の中身を確認する
# openssl x509 -text -noout -in server.crt Certificate: Data: Version: 3 (0x2) Serial Number: (略) Signature Algorithm: sha256WithRSAEncryption ←SHA-2(SHA256)の証明書 Issuer: C=US, O=GeoTrust Inc., CN=RapidSSL SHA256 CA - G3 Validity Not Before: Oct xx xx:xx:xx 2015 GMT ←開始日 Not After : Nov x xx:xx:xx 2018 GMT ←終了日 Subject: CN=www.example.info ←ドメイン確認 Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) ←2048bitを確認 Modulus: (略) Exponent: (略) X509v3 extensions: X509v3 Authority Key Identifier: keyid:(略) Authority Information Access: OCSP - URI:http://gv.symcd.com CA Issuers - URI:http://gv.symcb.com/gv.crt X509v3 Key Usage: critical Digital Signature, Key Encipherment X509v3 Extended Key Usage: TLS Web Server Authentication, TLS Web Client Authentication X509v3 Subject Alternative Name: DNS:www.example.info, DNS:example.info ← ドメイン確認 X509v3 CRL Distribution Points: Full Name: URI:http://gv.symcb.com/gv.crl X509v3 Basic Constraints: critical CA:FALSE X509v3 Certificate Policies: Policy: CPS: https://www.rapidssl.com/legal Signature Algorithm: sha256WithRSAEncryption (略)
パスフレーズ応答を削除(Apache再起動の度に確認が来るため)
# openssl rsa -in server.key -out server.key Enter pass phrase for server.key: ←パスフレーズ入力 writing RSA key
Apacheの設定変更
RapidSSLの中間証明書のインストール、SSL設定が必要
RapidSSLの中間証明書はGeoTtustのサイトにて取得
www.geotrust.co.jp
SHA-2の中間証明書を取得
中間証明書の作成
# vi /etc/pki/tls/certs/rapidssl-chain.crt -----BEGIN CERTIFICATE----- (略) -----END CERTIFICATE-----
先ほど取得した文字列をコピー、ペースト。
SSLの設定
# vi /etc/httpd/conf.d/ssl.conf ~以下を編集~ DocumentRoot "/var/www/html" ServerName www.example.info:443 SSLProtocol all -SSLv2 -SSLv3 SSLCertificateFile /etc/pki/tls/certs/server.crt SSLCertificateKeyFile /etc/pki/tls/certs/server.key SSLCertificateChainFile /etc/pki/tls/certs/rapidssl-chain.crt ※ 2019/03/24 記載漏れのため追記