通过 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 生成私钥。

 

◎ 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 来减少垃圾评论. 了解您的评论数据如何被处理.