驗證需要由http 80方式,因此網站需要開放80訪問
測試環境Centos7、WEB平台Nginx
1.安裝 acme.sh
※curl與目標網址之間只能1個空白,2個或以上的空白會失敗
#curl https://get.acme.sh | sh -s [email protected]

理論會自動設置全局別名 acme.sh(上圖紅勾處)、但有時候會失敗
Installing alias to ‘/root/.cshrc’
#source ~/.cshrc 或 #source ~/.bashrc
可以查看 安裝顯示提示 alias最後碼,若沒有再以source補完
2.申請憑證指令
# 生成 RSA 憑證:
acme.sh –issue -d blog.exsvc.cn -w /var/www/_網站路徑/
EX:
acme.sh –issue -d blog.example.com -w /var/www/


由於申請憑證時需要驗證,驗證會需要在網站跟目錄底下配置驗證文件
因此需要給程式知道,網站的路徑在何處以便驗證
指令完成後,憑證檔案預設路徑為 /root/.acme.sh/域名/
官方不建議直接取用,下一步驟為安裝憑證指令
3.安裝憑證指令
acme.sh --installcert -d blog.example.com \ --key-file /usr/local/etc/nginx/conf.d/ssl/private.key \ --fullchain-file /usr/local/etc/nginx/conf.d/ssl/certificate.crt \ --reloadcmd "service nginx reload"
--key-file 參數為憑證key檔案的安裝處 --fullchain-file 參數為憑證crt檔案的安裝處 --reloadcmd 參數用於讓web服務器重新載入新的憑證文件
範例中使用的是 nginx 服務器,您也可以更換成其它服務器。
再依照WEB服務器設置對應的SSL設定值
4.更新憑證
原則上acme.sh會自動判斷到期前自動更新、下列手動強制更新
acme.sh --renew -d 域名 --force
※其他指令
列表目前憑證
acme.sh --list
查看憑證資訊(包含先前設置過的reloadcmd)
acme.sh --info --domain example.com
修改 reload 指令
只要重新設定一次 --install-cert 即可
acme.sh --install-cert -d blog.example.com \
--reloadcmd "systemctl reload nginx"
移除憑證
acme.sh --remove -d blog.example.com