Letsencrypt.org CA免費證書使用
Let's 支持多中客戶端,這里使用acme.sh客戶端配置免費證書。
acme.sh優點:
- 純用Shell(Unix外殼)語言編寫的ACME協議客戶端。
- 完整的ACME協議實施。
- 支持ACME v1和ACME v2
- 支持ACME v2通配符證書
- 簡單,強大且非常易於使用。您只需要3分鍾即可學習。
- Bash,破折號和sh兼容。
- 讓我們加密免費證書客戶端的最簡單的shell腳本。
- 完全用Shell編寫,不依賴python或官方的Let's Encrypt客戶端。
- 只需一個腳本即可發布,續訂和自動安裝證書。
- 不需要
root/sudoer
訪問。 - Docker友好
- IPv6支持
- 以進行續訂或錯誤等Cron作業通知。
使用:
acme.sh安裝:
1、 在線安裝
curl https://get.acme.sh | sh
或者
wget -O - https://get.acme.sh | sh
2、git安裝
git clone https://github.com/Neilpang/acme.sh.git
cd ./acme.sh
./acme.sh --install
程序將執行3個操作:
- 創建和復制
acme.sh
到你的主目錄($HOME
)~/.acme.sh/
。所有證書也將放置在此文件夾中。 - 為創建別名
acme.sh=~/.acme.sh/acme.sh
。 - 如果需要,創建每日cron作業以檢查並更新證書。
cron 示例:
$HOME 為用戶目錄,注意修改為自己的實際用戶目錄
0 0 * * * "$HOME/.acme.sh"/acme.sh --cron --home "$HOME/.acme.sh" > /dev/null
幾種生成證書的情形:
-
只需頒發證書
acme.sh --issue -d example.com -w /home/wwwroot/example.com or: acme.sh --issue -d example.com -w /home/username/public_html or: acme.sh --issue -d example.com -w /var/www/html
-
同證書下多個子域名
acme.sh --issue -d example.com -d www.example.com -d cp.example.com -w /home/wwwroot/example.com
-w 參數為web服務的根路徑,必須要具備此文件的寫權限
證書將被放置在 ~/.acme.sh/example.com/
證書將每60天自動更新一次。
-
將證書安裝到Apache / Nginx等。
Apache example:
acme.sh --install-cert -d example.com \
--cert-file /path/to/certfile/in/apache/cert.pem \
--key-file /path/to/keyfile/in/apache/key.pem \
--fullchain-file /path/to/fullchain/certfile/apache/fullchain.pem \
--reloadcmd "service apache2 force-reload"
Nginx example:
acme.sh --install-cert -d example.com \
--key-file /path/to/keyfile/in/nginx/key.pem \
--fullchain-file /path/to/fullchain/nginx/cert.pem \
--reloadcmd "service nginx force-reload"
-
使用apache 模式
如果您正在運行Web服務器(Apache或Nginx),建議使用Webroot mode。 acme.sh --issue --apache -d example.com -d www.example.com -d cp.example.com 此模式不會講任何文件些人web根文件夾,第二個參數指定使用apache 模式,將強制使用apache插件。 此apache模式僅用於頒發證書,不會更改您的apache配置文件。您將需要配置您的網站配置文件以自己使用證書。我們不會亂您的apache服務器,不用擔心。
[更多示例](https : //github.com/Neilpang/acme.sh/wiki/How-to-issue-a-cert)
-
使用Nginx模式
同apache 模式一樣,如果正在使用web服務器nginx,推薦使用這種方式,只需將第二參數指定為nginx 即可 acme.sh --issue --nginx -d example.com -d www.example.com -d cp.example.com
注意事項:指定插件方式,注意將nginx,apacha的命令配置到了環境變量路徑下,可以直接使用nginx,httpd執行命令
-
發行通配符證書
acme.sh --issue -d example.com -d ' * .example.com '-- dns dns_cf
-
續訂證書
默認所有證書將每60天自動更新換一次,但是也可以強行更新: acme.sh --renew -d example.com --force
-
如何停止證書續訂
acme.sh --remove -d example.com [--ecc]
-
如何升級acme.sh
acme.sh正在不斷開發中,因此強烈建議使用最新代碼。
您可以將acme.sh更新為最新代碼:
acme.sh --upgrade
您還可以啟用自動升級:
acme.sh --upgrade --auto-upgrade
然后acme.sh將自動保持最新。
禁用自動升級:
acme.sh --upgrade --auto-upgrade 0