LoginSignup
15
14

More than 5 years have passed since last update.

ComodoのSSL証明書をApache+mod_sslにインストール

Last updated at Posted at 2015-08-23

Nginx版は「ComodoのSSL証明書をNginxにインストール」を参照。

証明書の購入

*.domain.com と dmn.com の二種類必要だったので、Comodo EssentialSSL Wildcard と Comodo PositiveSSL を購入。
販売代理店私は当初 SSLs で申し込んだものの、後になって GoGetSSL の方が安い上に管理画面が充実している事が判明したため、 SSLs はキャンセル。SSLs はチャット、メールサポート共に対応は早い。
販売代理店はいくつか検討しましたが、低価格ながらもサイトの作りがしっかりしている販売代理店は以下の通り。
* GoGetSSL
* CheapSSLSecurity
* NameCheap
* SSLs

Comodo EssentialSSL Wildcard用の証明書の作成

秘密鍵の作成

shell

$ cd /etc/pki/tls/certs/
$ openssl req -new -newkey rsa:2048 -nodes -keyout domain.com.key -out domain.com.csr
Generating a 2048 bit RSA private key
.+++
.....+++
writing new private key to 'domain.com.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) []:Tokyo
Locality Name (eg, city) [Default City]:Shibuya
Organization Name (eg, company) [Default Company Ltd]:Domain Company
Organizational Unit Name (eg, section) []:(Blank)
Common Name (eg, your name or your server's hostname) []:*.domain.com
Email Address []:admin@domain.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:(Blank)
An optional company name []:(Blank)

秘密鍵をアップロードし証明書を受け取る

  1. 生成した秘密鍵 (/etc/pki/tls/certs/domain.com.csr) の内容をコピーし、GoGetSSLの管理画面から送信。

  2. 諸々の手続き完了後、Comodoからバリデーション要求メールが送られてくる。指定のアドレスで認証を行うと、登録メールアドレスにZIPアーカイブが送られてくる。

認証完了後送られてくるメールに添付されているZIPアーカイブの内容。

ファイル名 種別
AddTrustExternalCARoot.crt ルート証明書
COMODORSAAddTrustCA.crt 中間証明書
COMODORSADomainValidationSecureServerCA.crt 中間証明書
STAR_domain_com.crt サーバ証明書

Apacheの設定

ZIPアーカイブのうち、3つのファイルを/etc/pki/tls/certs/domain.com.ca-bundle.crtにまとめる。

shell

$ cat STAR_domain_com.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt >> domain.com.ca-bundle.crt

/etc/pki/tls/certs/domain.com.crtを作成し、ZIPアーカイブのSTAR_domain_com.crtの内容をコピー。

shell

$ cat STAR_domain_com.crt >> domain.com.crt

一連の作業で作成したファイルは以下の4つ。

shell

$ ls -l /etc/pki/tls/certs/
-rw-r--r--  1 root root    5627 Aug 23 17:00 domain.com.ca-bundle.crt
-rw-r--r--  1 root root    1900 Aug 23 17:01 domain.com.crt
-rw-r--r--  1 root root    1033 Aug 23 16:46 domain.com.csr
-rw-r--r--  1 root root    1704 Aug 23 16:46 domain.com.key

VirtualHostの設定を行う。

shell

$ vi /etc/httpd/conf.d/vhost_domain.com.conf

<VirtualHost *:443>

    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/domain.com.crt
    SSLCertificateKeyFile /etc/pki/tls/certs/domain.com.key
    SSLCertificateChainFile /etc/pki/tls/certs/domain.com.ca-bundle.crt

</VirtualHost>

Comodo PositiveSSL用の証明書の作成

  • Comodo EssentialSSL Wildcard用の証明書の作成と手順は同じ。domain.com を dmn.com に置き換えるだけ。
  • 秘密鍵生成の際は、間違えてホスト名にワイルドカード指定しないこと。
shell

Common Name (eg, your name or your server's hostname) []:dmn.com

15
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
14