This commit is contained in:
yumoqing 2025-01-03 14:05:10 +08:00
parent 983a30e197
commit 4f5aa07b86
2 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,46 @@
# 使用dns检查发放lets encrypt的证书
## 依赖软件
* [certbot](https://certbot.eff.org)
* [acme-dns-certbot](https://github.com/joohoi/acme-dns-certbot-joohoi/raw/master/acme-dns-auth.py)
## 域名控制权
所使用的域名能增加域名解析
## 安装软件
### 安装certbot
以nginx pip为例
```
apt update
apt install python3 python3-venv libaugeas0
python3 -m venv /opt/certbot/
/opt/certbot/bin/pip install certbot certbot-nginx
ln -s /opt/certbot/bin/certbot /usr/bin/certbot
```
### 安装acme-dns-certbot
```
wget https://github.com/joohoi/acme-dns-certbot-joohoi/raw/master/acme-dns-auth.py
chmod +x acme-dns-auth.py
vi acme-dns-auth.py
####CHANGE FIRST LINE TO
#!/usr/bin/env python3
####END
mkdir mv /etc/letsencrypt/
mv acme-dns-auth.py /etc/letsencrypt/
```
## 申请证书
```
sudo certbot certonly --manual --manual-auth-hook /etc/letsencrypt/acme-dns-auth.py --preferred-challenges dns --debug-challenges -d \*.your-domain -d your-domain
```
按照程序输出中的内容类似这样_acme-challenge.psaqc.com CNAME 052a7281-14b4-42eb-8691-ca97618cc7ae.auth.acme-dns.io. )添加到你的域名的解析中。
解析生效后回车让程序执行完成,即完成了证书的申请
## 使用证书
生成的证书在/etc/letsencrypt/下寻找找到好可以将证书放在nginx可以找到的地方既可以使用了

View File

@ -112,6 +112,8 @@ sudo systemctl enable {name}.service
sudo systemctl start {name} sudo systemctl start {name}
""") """)
od.system('chmod +x script/*.sh')
with codecs.open(f'./conf/config.json', 'w', 'utf-8') as f: with codecs.open(f'./conf/config.json', 'w', 'utf-8') as f:
f.write(config_str) f.write(config_str)
@ -137,7 +139,7 @@ with codecs.open(f'{home}/bin/{venv}py', 'w', 'utf-8') as f:
with codecs.open(f'{home}/bin/{venv}pip', 'w', 'utf-8') as f: with codecs.open(f'{home}/bin/{venv}pip', 'w', 'utf-8') as f:
f.write(f"""#!/usr/bin/bash f.write(f"""#!/usr/bin/bash
~/ve/ms/bin/pip $* ~/ve/{venv}/bin/pip $*
""") """)
os.system(f'chmod +x {home}/bin/{venv}*') os.system(f'chmod +x {home}/bin/{venv}*')