広告:ページ内にてアフィリエイト広告を利用しています。
KUSANAGI

KUSANAGIのSSLの設定

サーバー証明書はドメイン同様年間で更新費用がかかるので個人ユーザーには縁遠いものでした。

一からサーバー証明書を設定するのはなかなか難儀ですが、常時SSLの需要が高まりリーズナブルなSSLも登場しています。

このページではkusanagiで用意したWordPressにSSL(サーバー証明書)を設定する手順をまとめます。

ここではLet’s Encrypt(無料)のサーバー証明書を使っていますので費用はかかりませんのでご安心を。

あらかじめ、プロビジョニング・WordPressをインストールしておきます。

KUSANAGIのプロビジョニングKUSANAGIのプロビジョニング ドメインの設定、ディレクトリの設定は「kusanagi provisionコマンド」で行います。 ...

SSLの設定

SSLの設定は「kusanagi ssl コマンド」で行います。

  • メールアドレス:hoge@example.com
  • プロファイル名:hogehoge
  • ドメイン:blog.example.com
[root@kusanagi71 kusanagi]# kusanagi ssl --email hoge@example.com hogehoge
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Cert not yet due for renewal
Keeping the existing certificate
-------------------------------------------------------------------------------
Certificate not yet due for renewal; no action taken.
-------------------------------------------------------------------------------
証明書の自動更新は既に無効です。何もしません。
unexpected status 403 Forbidden from log server:
{
"error_message": "This log is frozen, no further entries may be added.",
"success": false,
"i": "   __      ",
"c": "-=(o '-    ",
"e": "   `.-.\\   ",
"p": "   /|  \\\\  ",
"a": "   '|  ||  ",
"l": "    _\\_):,_"
}
Cannot execute ct-submit ct.googleapis.com/aviator < /etc/letsencrypt/live/blog.example.com/fullchain.pem
CTを有効化します。
nginx/httpd の設定を変更し、再起動しました。
完了しました。

httpsのポート(443)が開放されていない場合はiptablesで適宜開放するようにします。

iptables(ファイアウォール)の設定iptablesはパケットフィルタリング型のファイアウォールで、サーバー接続時の通信ルールを設定できます。 簡単に説明すると「使用する...

正しく動作している場合はURLの入力ボックスに「保護された通信」と表示されます。

場合によっては「!」のままになる場合も。

HTTPとHTTPSのコンテンツが混在している場合、セキュアな通信が行えないため「保護された通信」と表示されません。

これを回避するためにはエラーになっているコンテンツの読み込みをhttpsにするかどちらにも対応できる記述に変更する必要があります。

Firefoxでは認証局にLet’s Encryptが使われているのが確認できます。

httpsのリダイレクト設定

https以外でアクセスがあった際、httpsにリダイレクトする設定も用意されています。

[root@kusanagi71 kusanagi]# kusanagi ssl --https redirect hogehoge
mvno.hikaku-db.com 上のすべてのトラフィックを永久的にHTTPSにリダイレクトするよう設定します。
nginx/httpd の設定を変更し、再起動しました。
完了しました。

サーバー証明書の自動更新

Let’s Encryptのサーバー証明書の有効期限は90日と有料のサーバー証明書と比べると短いです。

都度更新するのは手間がかかるので自動更新の設定をしておきます。

[root@kusanagi71 kusanagi]# kusanagi ssl –auto on hogehoge
証明書の自動更新は既に無効です。何もしません。

「証明書の自動更新は既に無効です」と日本語がおかしいのですが翻訳の問題のようです。設定は問題ないとのこと(2017/2/22時点)

サーバー証明書有効期限19日前に以下の件名のメールが届きます。

Let’s Encrypt certificate expiration notice for domain “ドメイン名”

本文は以下の通り。

Hello,

Your certificate (or certificates) for the names listed below will expire in
19 days (on 20 Oct 17 17:07 +0000). Please make sure to renew
your certificate before then, or visitors to your website will encounter errors.

“ドメイン名”

For any questions or support, please visit https://community.letsencrypt.org/.
Unfortunately, we can’t provide support by email.

For details about when we send these emails, please visit
https://letsencrypt.org/docs/expiration-emails/. In particular, note
that this reminder email is still sent if you’ve obtained a slightly
different certificate by adding or removing names. If you’ve replaced
this certificate with a newer one that covers more or fewer names than
the list above, you may be able to ignore this message.

If you want to stop receiving all email from this address, click
http://mandrillapp.com/track/unsub.php?(パラメーター)
(Warning: this is a one-click action that cannot be undone)

Regards,
The Let’s Encrypt Team

念の為ブラウザからも確認したところ、間違いないようです。このメールはLet’s Encrypt Teamから自動送信されているリマインダーのようなので不要な場合は本文のリンクから停止することはできます。

iPhoneのSafariで接続できない

SSL適用後、iPhone(iOS10.2)のSafariで表示できない状態でした。

原因を調べていたところ以下の記事を見つけ、kusanagi ssl –ct offコマンドでオフにすることで表示できました。

[root@kusanagi71 nginx]# kusanagi ssl --ct off hogehoge

SSL Labsでチェック

Qualys SSL Labs社が提供している、SSL Server Testで脆弱性のチェックをしてみたところ問題なさそうな結果となりました。

設置後は是非チェックしてみてください。

https://www.ssllabs.com

最後に

以上でKUSANAGIのSSL設定は完了です。KUSANAGI Version 8.0.1-2では特に設定無しでHTTP/2にも対応されるので何ともお手軽なものです。