之前写过一篇在 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。
【相關連結】
- 在 Windows 申请 Let's Encrypt 通配符证书 | 老森常谈
- Releases · win-acme/win-acme · GitHub
- win-acme
- [apache] 安装免费 SSL 与设置 80 将 Windows 端口转到 443 | 在海洋中散步的码农 – 点博客
- Apache 重定向到 HTTPS – SSL 网站安全证书 – ztabox.com
- Windows 版 Let’s Encrypt for Apache | 老洪的 IT 学习系统








留下回复