Let’s Encrypt の証明書を手動(DNS-01)で発行した作業メモ

スポンサーリンク

CentOS Stream 9 環境で、Let’s Encrypt(Certbot)を使って SSL 証明書を発行した際の作業備忘録です。対象のWebサーバが古くてCertbotが入らなかったので、Web サーバとは別ホストから DNS 認証(DNS-01 チャレンジ)で発行しています。

環境

  • OS: AlmaLinux 9
  • 証明書発行ツール: certbot
  • 認証方式: DNS-01(手動)
  • ドメイン: tec-memo.com
  • 証明書利用先: 別サーバへファイルコピー

certbot のインストール(EPEL 有効化)

EPEL 有効化

CentOS Stream 9 では標準リポジトリに certbot が無いため、EPEL リポジトリを有効化します。

# dnf install -y epel-release

certbot のインストール

# dnf install certbot

Apache 用プラグインの追加(今回は未使用)

一応 Apache 用プラグインもインストール。
※ 今回は DNS-01 チャレンジのため Apache プラグインは使用していません。

# dnf install -y certbot python3-certbot-apache

certbot で証明書発行(DNS-01 / 手動)

certbot certonly   --manual   --preferred-challenges dns -d tec-memo.com

certonly:証明書の取得のみ(自動設定なし)
--manual:手動認証
--preferred-challenges dns:DNS-01 チャレンジ指定

Enter email address (used for urgent renewal and security notices)

(Enter 'c' to cancel):メールアドレスを入力
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at

https://letsencrypt.org/documents/LE-SA-v1.6-August-18-2025.pdf.
You must agree in order to register with the ACME server. Do you agree? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y(② 利用規約への同意どちらでも可) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing, once your first certificate is successfully issued, to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: N(EFF への情報共有の可否どちらでも可) Account registered. Requesting a certificate for tec-memo.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please deploy a DNS TXT record under the name: _acme-challenge.tec-memo.com. with the following value: 0eqpsertm560VEiLoaWsR3sdfeaw4DEwbDearfJfeiR Before continuing, verify the TXT record has been deployed. Depending on the DNS provider, this may take some time, from a few seconds to multiple minutes. You can check if it has finished deploying with aid of online tools, such as the Google Admin Toolbox: https://toolbox.googleapps.com/apps/dig/#TXT/_acme-challenge.tec-memo.com. Look for one or more bolded line(s) below the line ';ANSWER'. It should show the value(s) you've just added. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Press Enter to Continue

ここでEnterを押す前にDNSにTXTレコードを登録する。ここでは以下のようになる。

_acme-challenge.tec-memo.com CNAME 0eqpsertm560VEiLoaWsR3sdfeaw4DEwbDearfJfeiR

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue(DNS登録後、Enterを押す)
Certificate is saved at: /etc/letsencrypt/live/tec-memo.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/tec-memo.com/privkey.pem
This certificate expires on 2026-06-23.
These files will be updated when the certificate renews.

NEXT STEPS:
- This certificate will not be renewed automatically. Autorenewal of --manual certificates requires the use of an authentication hook script (--manual-auth-hook) but one was not provided. To renew this certificate, repeat this same certbot command before the certificate's expiry date.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

成功すると以下のディレクトリに各種証明書が作成されるので、あとは対象のWebサーバにコピーして証明書を更新するだけ。

# ls -l /etc/letsencrypt/archive/tec-memo.com/
合計 16
-rw-r--r-- 1 root root 1285  3月 26 09:38 cert1.pem (サーバ証明書)
-rw-r--r-- 1 root root 1566  3月 26 09:38 chain1.pem(中間証明書チェーン)
-rw-r--r-- 1 root root 2851  3月 26 09:38 fullchain1.pem(サーバ証明書 + 中間証明書)
-rw------- 1 root root  227  3月 26 09:38 privkey1.pem(秘密鍵)

対象サーバにコピーし、設置する

上記で作成されたファイルを証明書を更新したいサーバに配置して証明書を更新する。

コピーした後、実際に証明書を更新する手順はこちらを参照

コメント

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