Let’s Encrypt から 発行料 無しの証明を受け取り、Apache,sslにて使います

Let’s Encrypt

Let’s Encrypt とは、

Let’s Encrypt は、公共の利益のために運営されている、フリーで自動化されたオープンな認証局 (certificate authority; CA) です。

私たちは人々のために、ウェブサイトで HTTPS (SSL/TLS) を有効にするために必要なデジタル証明書を、無料で、私たちにできる最もユーザーフレンドリーな方法で発行しています。 私たちがこのようなことをする理由は、よりセキュアでプライバシーを尊重するウェブを作りたいと願っているからです。

https://letsencrypt.org/ja/about

Let’s Encrypt、有り難く、素晴らしいです。
https://letsencrypt.org/ja

https://www.server-world.info/query?os=Ubuntu_24.04&p=ssl&f=2
上記サイトを参考にしています。有難うございます。

Certbot を使う

$ sudo apt install certbot
以下の追加パッケージがインストールされます:
  python3-acme python3-certbot python3-configargparse python3-icu python3-josepy python3-parsedatetime python3-rfc3339
提案パッケージ:
  python-certbot-doc python3-certbot-apache python3-certbot-nginx python-acme-doc
以下のパッケージが新たにインストールされます:
  certbot python3-acme python3-certbot python3-configargparse python3-icu python3-josepy python3-parsedatetime python3-rfc3339
アップグレード: 0 個、新規インストール: 8 個、削除: 0 個、保留: 0 個。
980 kB のアーカイブを取得する必要があります。
$ sudo certbot --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
The requested apache plugin does not appear to be installed

$ sudo apt install python3-certbot-apache <--入れ忘れちゃった
以下の追加パッケージがインストールされます:
  augeas-lenses libaugeas0 python3-augeas
提案パッケージ:
  augeas-doc augeas-tools python-certbot-apache-doc
以下のパッケージが新たにインストールされます:
  augeas-lenses libaugeas0 python3-augeas python3-certbot-apache

インストールした後に思いついたのは、
証明を取得してから、Apache2を設定して、sslを有効化すれば良いのでは?
certonly オプションを使います : 証明書を取得または更新。インストールはしない

$ sudo certbot certonly --webroot -w /WEBROOTディレクトリ -d globe3.ddns.net
certonly : 証明書を取得または更新。インストールはしない
--webroot 認証のためにサーバーのwebrootフォルダーにファイルを配置します
-d 証明を取得するドメイン名 .区切りで表記します

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)

Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.5-February-24-2025.pdf. 
You must agree in order to register with the ACME server. Do you agree?

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

Account registered.
Requesting a certificate for globe3.ddns.net

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/globe3.ddns.net/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/globe3.ddns.net/privkey.pem
This certificate expires on 2025-08-11.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

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

Apache2 ssl を編集、有効化

/etc/apache2/sites-available/default-ssl.confを編集
# For Let's Encrypt.                                                                                     
SSLCertificateFile      /etc/letsencrypt/live/globe3.ddns.net/fullchain.pem
SSLCertificateKeyFile   /etc/letsencrypt/live/globe3.ddns.net/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf

/etc/letsencrypt/options-ssl-apache.confを編集
# Add vhost name to log entries:
# LogFormat ← ログフォーマットは別に設定しているため

$ sudo a2ensite default-ssl ← デフォルトSSLを有効化する
$ sudo systemctl restart apache2

apache オプションを用いて cerbotを再実行すると、以下のログが表示されました。

$ sudo certbot -d globe3.ddns.net --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Certificate not yet due for renewal

You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.
(ref: /etc/letsencrypt/renewal/globe3.ddns.net.conf)

What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Attempt to reinstall this existing certificate
2: Renew & replace the certificate (may be subject to CA rate limits)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):1

Deploying certificate

We were unable to find a vhost with a ServerName or Address of globe3.ddns.net.
Which virtual host would you like to choose?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: 000-default.conf               |                       |       | Enabled
2: default-ssl.conf               |                       | HTTPS | Enabled
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel):2
Successfully deployed certificate for globe3.ddns.net to /etc/apache2/sites-enabled/default-ssl.conf
Congratulations! You have successfully enabled HTTPS on https://globe3.ddns.net
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/etc/letsencrypt/options-ssl-apache.conf を編集

コメント