在Windows下使用Apache架站時,申請Let's Encrypt的SSL憑證的步驟:
1.確認web的port 80可以連線
有http自動轉https的話要關掉
2.下載win-acme
解壓縮後執行wacs.exe(可能要管理員權限)
3.wacs.exe操作如下
選m
選2
輸入網址(不用加https)
選4
選1
輸入網站根目錄位置
選2
選2
輸入存檔SSL憑證的位置
選1
選5
選3
之後enter按到底,會開始自動申請憑證,申請成功後按q離開wacs.exe
4.修改http-ssl.conf
加入或修改下面三行
SSLCertificateFile "SSL憑證存檔位置/網站名稱-crt.pem"
SSLCertificateKeyFile "SSL憑證存檔位置/網站名稱-key.pem"
SSLCertificateChainFile "SSL憑證存檔位置/網站名稱-chain.pem"
5.重啟apache
6.自動更新憑證
寫一個bat,加到工作排程
cd C:/win-acme(就是解壓縮win-acme的地方)
wacs.exe --renew --force
net stop Apache2.4 && net start Apache2.4
7.追記
如果是不能直接登入網站主機只能使用網頁空間的狀況,必須先在自己的電腦上申請憑證的認證密碼,然後再上傳到網頁空間中提供驗證,方式如下:
下載 ssl-certbot
https://www.markkulab.net/2021/12/26/ssl-certbot/
https://github.com/certbot/certbot/releases/download/v1.22.0/certbot-beta-installer-win32.exe
安裝 ssl-certbot後在cmd中
C:\Program Files (x86)\Certbot\bin> 輸入
certbot certonly --manual --preferred-challenges http -d 你的網址
中間會生成檔案,上傳到指定位置,然後進行驗證
1. Certbot 會顯示驗證資訊:
Create a file containing just this data:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
And make it available on your web server at this URL:
http://你的網址/.well-known/acme-challenge/yyyyyyyyyyyyy
2. 透過 FTP 上傳 `.well-known` 資料夾到 `你的網址` 的網站根目錄
3. 測試 URL:
http://你的網址/.well-known/acme-challenge/yyyyyyyyyyyyy
確認瀏覽器可以看到驗證字串
4. 回到 Certbot 按 Enter 完成驗證
5. 驗證成功後憑證會在:
C:\Certbot\live\你的網址\
├── fullchain.pem (完整憑證鏈)
├── privkey.pem (私鑰)
├── cert.pem (憑證)
└── chain.pem (中繼憑證)









留言
張貼留言