[Let’s Encrypt]ワイルドカードサーバ証明書を取得

Wordpress

9個のサブドメインでWordPressをマルチサイト化しているけど、このサブドメインのサーバ証明書の更新がめんどくさい…

私はDNS認証をしているので、
– サーバにSSHで入る。
– certbotのコマンドを叩く。
– DNSを書き換え
– certbotのコマンドの続き。
これを9回…これは面倒…



Let’s Encryptにワイルドカードサーバ証明書があるじゃないの!!ってことでサブドメイン毎にサーバ証明を取得していたが、ワイルドカード証明書にすることにより時間短縮だ!!

証明書の発行

$ sudo certbot certonly --manual --debug --email user@example.com  -d *.example.com --preferred-challenges dns --manual-public-ip-logging-ok
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for example.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.example.com with the following value:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.com/privkey.pem
   Your cert will expire on 2020-11-30. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Nginxの証明書ファイルパスを変更

server {
    listen 443 ssl;
    server_name sample.example.com;

    #ssl_certificate /etc/letsencrypt/live/sample.example.com/fullchain.pem;
    #ssl_certificate_key /etc/letsencrypt/live/sample.example.com/privkey.pem;

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    include global/wordpress.conf;
}

Nginxの設定ファイルに問題ないかチェック

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

まとめ

これでだいぶ楽になったぞ!
ホントは、DNS認証せずに「certbot renew」コマンド一発でできればよいのだけれど…
これはまた今後の課題かな。

コメント

タイトルとURLをコピーしました