< 自用文儿 使用 acme 获取网站证书 > ACME 脚本 script: acme.sh 获得证书 觉得比 certbot 方便
前言:
新买了一个 VPS 主机, 同在日本的阿里云上 VPM 一样,配置了一个出口。 出口要使用证书,上次用的都是 certbot 做的,前些天扫到 acme.sh,这次用它来试试。
官网链接: https://github.com/acmesh-official/acme.sh
环境准备:
- 域名:daven.us
- 主机:us
- 公网IP:8.8.8.9
- 已有 us.daven.us 的 A 记录
配置过程:
1. 下载脚本 script :acme.sh
curl https://get.acme.sh | sh
下载后运行acme.sh
2. 重新加载(执行)当前用户的 bash 配置文件
source ~/.bashrc
从上图看到, 每次登录。会运行 /root/.acme.sh/acme.sh.env 脚本。
3. 注册 acme 账号
~/.acme.sh/acme.sh --register-account -m daven@gmail.com
4. 设置证书颁发机构
~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
使用 letsencrypt 为默认的证书颁发机构
5. 为域名申请证书
~/.acme.sh/acme.sh --issue -d us.daven.us --alpn
申请一个三级域名的证书:us.daven.us
--alpn 参数是使用 443 端口验证域名所有权
注:主机 us 上有应用占用 443, 所以用它来验证。
6.安装已经申请好的证书
~/.acme.sh/acme.sh --install-cert -d us.daven.us --key-file /etc/***y/cert/privkey.pem --fullchain-file /etc/***y/cert/fullchain.pem --ecc
解释:
把属于 us.daven.us 的两个证书,以指定的文件名放到 /etc/***y/cert/ 目录下。 并以 ecc 加密
优点:
与 certbot 比较:
不需要安装 Python
不需要配置 Python venv 虚拟环境, 软件包与依赖
据说会自动更新