Let's EncryptでSSL証明書の新規作成と自動更新(dns-01編)

検証環境

想定サーバー・ドメイン

DNSコンテンツサーバー側

SSLサーバー側

インストール

DNSコンテンツサーバーの設定

named.conf の設定例

include "ダイナミックアップデートキーファイル名";

zone "example.jp" {
    type master;
    file "example.jpゾーンファイル名";
};

zone "_acme-challenge.www.example.jp" {
    type master;
    file "_acme-challenge.www.example.jpゾーンファイル名";
    update-policy {
        grant ダイナミックアップデートキー名 name _acme-challenge.www.example.jp. TXT;
    };
};

example.jp ゾーンファイルの設定例

$TTL               300

@                       IN SOA ns.example.jp. domain.example.jp. (
                               2017032201 ; serial
                               7200       ; refresh (2 hours)
                               900        ; retry (15 minutes)
                               2419200    ; expire (4 weeks)
                               86400      ; minimum (1 day)
                               )
                        IN NS ns
_acme-challenge.www     IN NS ns

_acme-challenge.www.example.jp ゾーンファイルの設定例

$TTL               300

@                       IN SOA ns.example.jp. domain.example.jp. (
                               2017032201 ; serial
                               7200       ; refresh (2 hours)
                               900        ; retry (15 minutes)
                               2419200    ; expire (4 weeks)
                               86400      ; minimum (1 day)
                               )
                        IN NS ns

ダイナミックアップデートキーファイルの設定例

key "キー名" {
    algorithm hmac-sha256;
    secret "PfzeGvXiOqtPOwQJY/iNFrvlD3/eKAHRZ0TbyK5GYII=";
};

上記ファイルは以下のコマンドにより生成することができる。

tsig-keygen -a hmac-sha256 キー名 > ダイナミックアップデートキーファイル名
chmod 0400 ダイナミックアップデートキーファイル名

本例における具体的設定例

key "ns-www." {
    algorithm hmac-sha256;
    secret "PfzeGvXiOqtPOwQJY/iNFrvlD3/eKAHRZ0TbyK5GYII=";
};

参考文献