LoginSignup
3

More than 5 years have passed since last update.

以前と少し変わったApache2.4系のSSL証明書の設定

Posted at

0. 環境

Apache 2.4.8以降

1. サーバ証明書発行まで

サーバにて秘密鍵とCSRの作成

openssl req -new -newkey rsa:2048 -nodes -keyout SITENAME.com.key -out SITENAME.com.csr

-> その後、SSL証明書購入サイトで申請へ。
※SITENAME.comなどはドメインなどお好きなように変えてください。

2. サーバ証明書更新作業

届いた証明書

  • AddTrustExternalCARoot.crt (ルート証明書)
  • COMODORSAAddTrustCA.crt (中間証明書1)
  • COMMODRSADomainValidationSecureServerCA.crt (中間証明書2)
  • STAR_SITENAME_com.crt (サーバ証明書)

※今回のケースはcomod sslです。

本番用に証明書をまとめる

apache 2.4系ではSSLCertificateFile ディレクティブにサーバ証明書、中間証明書、ルート証明書をまとめて指定する必要があります。

SITENAME.com.crt-ca-root.crt

cat SITENAME.com.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt >> SITENAME.com.crt-ca-root.crt

◆内訳
- サーバ証明書: STAR_SITENAME_com.crt
- 中間証明書1: COMMODRSADomainValidationSecureServerCA.crt
- 中間証明書2: COMODORSAAddTrustCA.crt
- ルート証明書: AddTrustExternalCARoot.crt

※内訳の順のように、サーバ証明書、中間証明書、ルート証明書の順になるのが正しいです。

その他本番への反映

※以下のような設定ですと、シンボリックリンクを張り直すだけで、ssl.confの修正は不要となります。

/etc/httpd/conf.d/ssl.conf
SSLCertificateFile /etc/httpd/conf.d/ssl/current/SITENAME.com.crt-ca-root.crt
SSLCertificateKeyFile /etc/httpd/conf.d/ssl/current/SITENAME.com.key

◆秘密鍵、証明書ファイルの設置後、シンボリックリンクの貼り直し
cd /etc/httpd/etc/httpd/conf.d/ssl/
unlink current
ln -s 2017.5.16/ current

◆apacheの再起動前にシンタックスの確認
httpd -t

◆再起動
service httpd restart
service httpd status

参考

・apache 2.4におけるSSL証明書の設定http://qiita.com/bageljp@github/items/6b9876b7571852284ead

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
3