74 lines
1.5 KiB
Markdown
74 lines
1.5 KiB
Markdown
---
|
|
title: 使用 acme.sh 来管理 letsencrypt 证书
|
|
date: 2021-08-16 16:15:09
|
|
tags:
|
|
---
|
|
|
|
## 安装 acme.sh ##
|
|
```shell
|
|
curl https://get.acme.sh | sh
|
|
```
|
|
安装完毕后可以使用 `acme.sh --version` 检查状态
|
|
```shell
|
|
# acme.sh --version
|
|
https://github.com/acmesh-official/acme.sh
|
|
v3.0.1
|
|
```
|
|
|
|
如果需要升级 `acme.sh` 则运行
|
|
```shell
|
|
# 升级到最新版
|
|
acme.sh --upgrade
|
|
|
|
# 开启自动升级
|
|
acme.sh --upgrade --auto-upgrade
|
|
|
|
# 关闭自动升级
|
|
acme.sh --upgrade --auto-upgrade 0
|
|
```
|
|
|
|
## 生成证书 ##
|
|
<!-- more -->
|
|
|
|
### HTTP 认证方式 ###
|
|
```shell
|
|
acme.sh --issue -d example.com -d www.example.com --webroot /home/wwwroot/example.com/
|
|
```
|
|
|
|
### DNS 认证方式 ###
|
|
各大 dns 提供商的使用方式参考[此处](https://github.com/acmesh-official/acme.sh/wiki/dnsapi)
|
|
|
|
此处以 cloudflare 为例:
|
|
```shell
|
|
export CF_Token="sdfsdfsdfljlbjkljlkjsdfoiwje"
|
|
export CF_Account_ID="xxxxxxxxxx"
|
|
export CF_Zone_ID="xxxxxxxxxx"
|
|
|
|
acme.sh --issue --dns dns_cf -d example.com -d *.example.com --server letsencrypt
|
|
```
|
|
|
|
|
|
## 操作已安装证书 ##
|
|
```shell
|
|
# 查看已安装证书
|
|
acme.sh --list
|
|
|
|
# 删除证书
|
|
acme.sh remove <SAN_domains>
|
|
```
|
|
|
|
## 安装证书 ##
|
|
```shell
|
|
# 以 example.com 为例
|
|
acme.sh --installcert -d example.com \
|
|
--key-file /usr/local/nginx/ssl/example.com.key \
|
|
--fullchain-file /usr/local/nginx/ssl/fullchain.cer \
|
|
--reloadcmd "systemctl reload nginx ; systemctl restart v2ray"
|
|
```
|
|
|
|
## 更新证书 ##
|
|
如果需要手动续签,则执行
|
|
```shell
|
|
acme.sh --renew -d example.com --force
|
|
```
|