1 頁 (共 1 頁)

Windows 2003 IIS6.0使用Letsencrypt憑證自動更新的方法

文章發表於 : 2018年 3月 23日, 09:01
kaku
1.因為letsencrypt-win-simple需要使用.net 4.5,所以不支援windows 2003
故改用ZeroSSL client來執行產生、更新憑證
https://zerossl.com/
https://github.com/do-know/Crypt-LE/releases
產出憑證指令:
(DNS驗證產出)
D:\le32.exe --key account.key --csr D:\mydomain.csr --csr-key D:\mydomain.key --crt D:\mydomain.crt --domains "www.race.com.tw" --generate-missing --handle-as dns --live
(HTTP驗證產出)
D:\le32.exe --key account.key --csr C:\mydomain.csr --csr-key C:\mydomain.key --crt C:\mydomain.crt --domains "vwww.race.com.tw" --generate-missing --live
le32.zip

使用DNS驗證,需要修改DNS的設定:
DNS-Verify.jpg

使用HTTP驗證,需要用指令建立目錄".well-known"及其子目錄"acme-challenge",並修改其MIME的設定:
HTTP-Verify.jpg


2.需要安裝Openssl-Win32來產出.pfx檔
產出指令:
C:\OpenSSL-Win32\bin\openssl pkcs12 -export -nodes -out C:\certificate.pfx -inkey D:\mydomain.key -in D:\mydomain.crt -password pass:1234
Win32OpenSSL_Light-1_1_0f.zip

3.每日排程憑證更新
(DNS驗證更新) <=不建議用
D:\le32.exe --key D:\account.key --csr D:\mydomain.csr --csr-key D:\mydomain.key --crt D:\mydomain.crt --domains "www.race.com.tw" --generate-missing --handle-as dns --renew 31 --issue-code 100 --live --export-pfx 1234
(HTTP驗證更新)
D:\le32.exe --key D:\account.key --csr D:\mydomain.csr --csr-key D:\mydomain.key --crt D:\mydomain.crt --domains "www.race.com.tw" --path C:/Inetpub/wwwroot/.well-known/acme-challenge/ --generate-missing --renew 31 --issue-code 100 --live --export-pfx 1234

if errorlevel 100 ( echo Time to update the certificate file and reload the server )

**可以把步驟3+2(放在3的最下面)的指令寫成一個批次檔,用排程每日執行.

4.排程使用IISCertDeploy.vbs來匯入憑證至IIS
cscript.exe IISCertDeploy.vbs -c c:\certificate.pfx -p 1234 -i w3svc/1 -s web1 -u Administrator -pwd 12345678 -q ON

PS.如果憑證已存在,會造成IISCertDeploy.vbs在匯入憑證至IIS時會跳出問你是否要覆寫Yes/No
所以要修改部份程式,讓它強制執行覆寫!!
修改後的vbs:
IISCertDeploy.zip

使用IISCertDeploy.vbs需安裝IIS 6.0 Resource Kit和 WinScript 5.7
iis60rkt.zip

scripten.zip