(Win10)Apache+Let’s EncryptでSSL化する(マルチドメイン対応)

Let’s EncryptでwebサーバーをSSL化し、その後自動更新までさせたいという指南記事は多数みつかるため、私がやった事だけを忘備録として記録しておきます。

準備

Let’s Encryptにアカウントを登録し、ドメイン毎のSSL証明書を取得して更新までしてくれるcertbotを
以下のURLからダウンロードしてインストールします。

https://certbot.eff.org/lets-encrypt/windows-apache

ページの中ほどにダウンロードリンクがあるので直リン

https://dl.eff.org/certbot-beta-installer-win32.exe

インストールが完了したら管理者モードでコマンドプロンプトを起動しておきます。

SSL証明書の取得

SSL証明書を取得する際Let’s EncryptがWebサーバーの所在確認をするためCertbotの内蔵webサーバーを使用します。
そのためApacheを止めておく必要がありますのでApacheを停止させておきます。

管理者モードでコマンドプロンプトを起動して、certbot.exe が入っているフォルダまで移動しておきます。

cd C:\Program Files (x86)\Certbot\bin

certbot certonly
でcertbotを実行します。

以下入力したところを赤色マーカーで反転してあります。

C:\Program Files (x86)\Certbot\bin>certbot.exe certonly

Saving debug log to C:\Certbot\log\letsencrypt.log

How would you like to authenticate with the ACME CA?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Spin up a temporary webserver (standalone)
2: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
Plugins selected: Authenticator standalone, Installer None
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): xxxxxxxxxx@gmail.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at

404 Page not found - Let's Encrypt
Let's Encrypt is a free, automated, and open certificate authority brought to you by the nonprofit Internet Security Res...
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: y Account registered.

ドメインを入力します。

Please enter in your domain name(s) (comma and/or space separated)  (Enter 'c'
to cancel): debugprint.com
Requesting a certificate for debugprint.com
Performing the following challenges:
http-01 challenge for debugprint.com
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
Congratulations! Your certificate and chain have been saved at:
   C:\Certbot\live\debugprint.com\fullchain.pem
   Your key file has been saved at:
   C:\Certbot\live\debugprint.com\privkey.pem
   Your certificate will expire on 2022-01-24. 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

黄色マーカーの位置に証明書が作成されました。
有効期限は 2022年1月24日までです。
それまでにコマンドプロンプトで certbot renew とすれば期限が更新されます。

Apacheへ設定

httpd-vhosts.conf に以下の記述を追加しました。(黄色、および赤色マーカーの所)

<VirtualHost *:80>
    ServerName debugprint.com
    DocumentRoot c:\htdocs\debugprint.com

    <Directory c:\htdocs\debugprint.com>
	Options FollowSymlinks Includes
     	AllowOverride All
    	Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:443>
    ServerName debugprint.com
    DocumentRoot c:\htdocs\debugprint.com

    SSLEngine on
    SSLCertificateFile "C:\Certbot\live\debugprint.com\cert.pem"
    SSLCertificateKeyFile "C:\Certbot\live\debugprint.com\privkey.pem"


    <Directory c:\htdocs\debugprint.com>

	Options FollowSymlinks Includes
     	AllowOverride All
    	Require all granted


    </Directory>
</VirtualHost>

Apacheを起動 or 再起動するとSSLアクセスが有効になっています。
ドメインを追加するときは再度 crtbot certonly を実行します。

https://debugprint.com/
https://www9057uj.sakura.ne.jp/

Let’s Encrypt証明書更新

Let’s Encryptは3か月の有効期限付きです。
管理者モードでコマンドプロンプトを立ち上げ、 certbot renew を実行することで証明書の期限が更新されます。

コメント

  1. […] (Win10)Apache+Let's EncryptでSSL化する(マルチドメイン対応) […]

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