生成证书
- acme.sh实现了 acme 协议,一般有两种方式验证:http验证和dns验证
- http验证
```shell http方式需要在你的网站根目录放置一个文件验证所有权,验证通过后就可以生成证书了。 acme.sh —issue -d (域名) -d (域名) —webroot (网页根路径) acme.sh —issue -d hezhiwei.chatuwish.com —webroot /home/wwwroot/chatuwish.com/
- http验证
只需要指定域名, 并指定域名所在的网站根目录. acme.sh 会全自动的生成验证文件, 并放到网站的根目录, 然后自动完成验证. 最后会删除验证文件. 整个过程没有任何副作用。
- dns验证
```shell
dns验证的是通过域名解析商提供的api来自动添加txt记录完成验证
前提得先到域名解析商提供里生成DNS解析Api_Key,然后写入 "~/.acme.sh/account.conf" 配置文件中
使用DNS的方式配置ssl
克隆项目
1、创建普通用户
2、克隆项目和脚本
git clone https://github.com/acmesh-official/acme.sh.git
cd ./acme.sh
./acme.sh --install -m (域名)
./acme.sh --install -m hezhiwei.chatuwish.com
# 或者使用
curl https://get.acme.sh | sh
3、运行脚本后自动会在当前用户的家目录创建一个隐藏目录,和创建一个定时任务每天检查证书是否过期,需要更新 则会自动更新证书.
隐藏目录:~/.acme.sh
56 0 * * * "/ops/.acme.sh"/acme.sh --cron --home "/ops/.acme.sh" > /dev/null
4、在当前用户设置脚本别名
vim .bash_profile
acme.sh=~/.acme.sh/acme.sh
source .bash_profile
使用DNS的方式配置ssl
# GoDaddy使用DNS验证域名,需要(前往GoDaddy新增 API Key:)
1、前往 GoDaddy 新增 API Key:
https://developer.godaddy.com/keys
2、生成Key_api
2.1、点击:"Create New API Key"
2.2、在"Name(Optional)"中输入"acme.sh auto Let's Encrypt"
2.3、在"Environment"中选择"Production"
2.4、点击Next
3、获取Api_Key
将Key和Secret保存起来
vim ~/.acme.sh/account.conf
export GD_Key="xxxxxtpTEP3_xxxxxx9dn3Tdwv8PZxxxxx"
export GD_Secret="xxxxxtmxxxxxZwuWrxxxxx"
:wq
办理证书
脚本使用
acme.sh --upgrade # 手动更新脚本
acme.sh --upgrade --auto-upgrade # 自动更新脚本
acme.sh --upgrade --auto-upgrade 0 # 禁止更新脚本
1、配置邮箱地址
acme.sh --register-account -m (邮箱地址)
acme.sh --register-account -m vpn@163.com
2、使用DNS的方式验证域名
acme.sh --issue --dns dns_gd -d (域名) -d (域名) -d (*.DomainName.com)
acme.sh --issue --dns dns_gd -d vpn.chatuwish.com
3、获取证书到nginx的ssl目录
acme.sh --installcert -d vpn.chatuwish.com \
--key-file /usr/local/nginx/conf/cert/vpn.chatuwish.com/key.pem \
--fullchain-file /usr/local/nginx/conf/cert/vpn.chatuwish.com/cert.pem \
--reloadcmd "nginx -s reload"