centos 7 配置certbot

snap方式安装certbot

certbot 是python 工具安装和升级容易造成包损坏等相关问题。

使用官方推荐方式安装 ,这里依赖了一个三方的环境隔离软件snap

https://certbot.eff.org/instructions?ws=other&os=centosrhel7

 

使用阿里云插件

sudo snap install certbot-dns-aliyun

sudo snap set certbot trust-plugin-with-root=ok

sudo snap connect certbot:plugin certbot-dns-aliyun

certbot plugins

配置密钥签发证书

certbot certonly --authenticator=dns-aliyun  --dns-aliyun-credentials=/root/.certbot/credentials.ini  -d test.nihao.cn -d "*.test.nihao.cn"

 

也可以选择maunal 的方式进行证书申请

certbot -d woaixuexi.cn --manual --manual-auth-hook 'sh /data/scripts/certbot_root_hook' --preferred-challenges http certonly

cat /data/scripts/certbot_root_hook 
#!/bin/bash
function old {
path= /usr/local/nginx/html/.well-known/acme-challenge
cd $path
git pull origin master
touch ${CERTBOT_TOKEN}
git add ${CERTBOT_TOKEN}
git commit -m "${CERTBOT_DOMAIN} 提交认证文件 ${CERTBOT_TOKEN} "
git push origin master
}

function new {
echo ${CERTBOT_VALIDATION}   > /usr/local/nginx/html/.well-known/acme-challenge/${CERTBOT_TOKEN}
}
new

--preferred-challenges 可以填写 dns 或者http。dns 方式通过dns txt记录进行验证;http 方式通过写入 .well-known/acme-challenge/plabXCawLKD3sEnfWxxxxxxxxxxxx 文件进行验证,但是验证完后还有查询下域名的A记录,国内有些cn 域名可能会出现以下报错,解决方案是找时间重试,或者在运营商那里提高自己dns服务器等级。

Detail: During secondary validation: DNS problem: query timed out looking up A for woaixuexi.cn

posted @ 2022-01-10 21:26  萱乐庆foreverlove  阅读(149)  评论(0编辑  收藏  举报