通过 WIN-ACME 申请并自动更新 Windows Apache 上的 Let’s Encrypt 证书

之前写过一篇在 Windows 申请 Let's Encrypt 通配符证书」,该篇主要是通过 “Get HTTPS for free!” 网站以手动方式申请或延长证书。最近在架设新网站时,尝试用 WIN-ACME 工具来申请,以方便之后使用其自动续期 (续约) 功能。

 

◎ 首先至 WIN-ACME 的 GitHub 下載最新的工具這邊以 win-acme.v2.1.22.1260.x64.pluggable.zip 為範例

◎ 下載完成並解壓縮後以「系統管理員身分」執行 wacs.exe

◎ 接下來主要都是以 WIN-ACME 官方針對 apache 環境的範例设置。

 

◎ Enter “m”,手動設定各參數

 

◎ Enter “m或按 Enter (預設 m),手動設定各參數

 

◎ 輸入要申請憑證的網址如 www.abc.com

 

◎ 為此域名輸入一個好識別的別名或是按 Enter 使用預設值

 

◎ Enter “1”,提供本機網站目錄路徑以進行域名驗證

 

◎ 輸入本機網站根目錄路徑如 C:\Web\Apache24\htdocs\abc

 

◎ Enter “yes”,允許程式複製 web.config 至網站目錄做驗證

 

◎ Enter “2” 或按 Enter (預設 2),以 RSA 產生 private key

 

◎ Enter “2”,以產生 apache 適用的 PEM 憑證檔案

 

◎ 輸入欲存放憑證檔案的目錄路徑如 C:\Web\SSL

 

◎ Enter “2”,Add a password to the private key,Or enter “1” Do not encrypt。

 

◎ If you do not need to generate a second certificate,Enter “5” 或按 Enter (預設 5) Continue。

 

◎ If there are no special requirements,Enter “3” 或按 Enter (預設 3) Continue。

 

◎ After the validation is passed,A schedule to check certificate updates will be added in 'Task Scheduler',If there is no need to run this task under a specific account,Enter “No” Continue。

 

◎ At this point,The certificate application is complete。

 

◎ Next, you can check the newly generated certificate in the certificate directory。

Note. *-crt.pem + *-chain-only.pem = *-chain.pem

 

◎ 在「工作排程器」可以看到新增了一個 WIN-ACME 的項目

 

◎ 開啟 apache 的 httpd-ahssl.conf (或 httpd-ssl.conf 或 httpd.conf看你的環境),增加一組 SSL 的 VirtualHost

<VirtualHost *:443>
  SSLEngine on
  ServerName www.abc.com:443
  SSLCertificateFile "C:\Web\SSL\www.abc.com-chain.pem"
  SSLCertificateKeyFile "C:\Web\SSL\www.abc.com-key.pem"
  DocumentRoot "${SRVROOT}/htdocs/abc"
</virtualhost>

 

◎ 如果 80 port 的 VirtualHost 不關但想將 80 自動轉至 443,可在 80 port 的 VirtualHost 增加Redirect參數

<VirtualHost *>
 DocumentRoot C:\Web\Apache24\htdocs\abc
 ServerName www.abc.com
 Redirect / https://www.abc.com/
</VirtualHost>

Note. https://www.abc.com/ 後面要有斜線這樣才會將 http://www.abc.com/def 導至 https://www.abc.com/def否則會變成 http://www.abc.comdef

 

【相關連結】

留下回复

您的电子邮件地址不会被公开. 必填项已标注 *

本网站使用 Akismet 来减少垃圾评论. 了解您的评论数据如何被处理.