作者:E4b9a6, 创建:2023-09-18, 字数:1553, 已阅:117, 最后更新:2023-09-18
Let's Encrypt是一个由互联网安全研究集团(ISRG)运营的非营利证书颁发机构,免费提供X.509传输层安全(TLS)加密证书
它是世界上最大的认证机构,其赞助商包括电子前沿基金会(EFF)、Mozilla基金会、OVH、思科系统、Facebook、谷歌Chrome等
Let's Encrypt官方推荐certbot程序,利用这个程序可以做到自动签发子域名证书,但实际使用中也有2个缺点
基于2个缺点,采用docker
来签发会方便很多,以下基于Debian11
首先安装docker
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add the repository to Apt sources:
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update -y
# Install dokcer
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
运行注册如下,会在当前目录下生成letsencrypt
文件夹,保留这个文件夹续签即可
sudo docker run -it --rm --name certbot -v "$(pwd)/letsencrypt/letsencrypt":/etc/letsencrypt -v "$(pwd)/letsencrypt/lib":/var/lib/letsencrypt certbot/certbot certonly -d "*.chancel.me" -d chancel.me --manual --preferred-challenges dns
等到需要续签(前30天内),运行如下指令就可以续签
sudo docker run -it --rm --name certbot -v "$(pwd)/letsencrypt/letsencrypt":/etc/letsencrypt -v "$(pwd)/letsencrypt/lib":/var/lib/letsencrypt certbot/certbot renew