可以从 zerossl 生成免费的证书,有效期90天
curl https://get.acme.sh | sh -s email=你的email
如上,是最简单的安装方法,但可能不会成功(因为这个域名访问不了raw.githubusercontent.com
),最稳妥的方法是下面这种
git clone https://github.com/acmesh-official/acme.sh.git
cd acme.sh
[root@iZbp1430s16l9piu268n8rZ acme.sh]# ./acme.sh --install -m 你的email
[Fri Apr 8 19:05:22 CST 2022] It is recommended to install socat first.
[Fri Apr 8 19:05:22 CST 2022] We use socat for standalone server if you use standalone mode.
[Fri Apr 8 19:05:22 CST 2022] If you don't use standalone mode, just ignore this warning.
[Fri Apr 8 19:05:22 CST 2022] Installing to /root/.acme.sh
[Fri Apr 8 19:05:22 CST 2022] Installed to /root/.acme.sh/acme.sh
[Fri Apr 8 19:05:22 CST 2022] Installing alias to '/root/.bashrc'
[Fri Apr 8 19:05:22 CST 2022] OK, Close and reopen your terminal to start using acme.sh
[Fri Apr 8 19:05:22 CST 2022] Installing alias to '/root/.cshrc'
[Fri Apr 8 19:05:23 CST 2022] Installing alias to '/root/.tcshrc'
[Fri Apr 8 19:05:23 CST 2022] Installing cron job
no crontab for root
no crontab for root
[Fri Apr 8 19:05:23 CST 2022] Good, bash is found, so change the shebang to use bash as preferred.
[Fri Apr 8 19:05:24 CST 2022] OK
验证是否安装成功
注意,你可能需要关闭当前ssh链接,重新打开终端才能生效
[vagrant@nfsFileSystem ~]$ acme.sh -h
https://github.com/acmesh-official/acme.sh
v3.0.2
Usage: acme.sh <command> ... [parameters ...]
Commands:
-h, --help Show this help message.
-v, --version Show version info.
--install Install acme.sh to your system.
--uninstall Uninstall acme.sh, and uninstall the cron job.
--upgrade Upgrade acme.sh to the latest code from https://github.com/acmesh-official/acme.sh.
--issue Issue a cert.
...
安装成功后会在当前用户下创建一条计划任务,用来检测所有证书是否需要更新,或者 应用本身是否需要更新
19 0 * * * "/home/vagrant/.acme.sh"/acme.sh --cron --home "/home/vagrant/.acme.sh" > /dev/null
生成证书需要验证你的域名所有权。acme.sh 实现了 acme 协议支持的所有验证协议,一般有 http 和 dns 两种验证方式。 这里介绍几种常用的验证方式。
acme.sh --issue -d portainer.cuiwei.net --webroot /data/www/portainer/web/ --debug
执行上面的命令会在/data/www/portainer/web/
目录自动生成一个类似.well-known/acme-challenge/tvPCfBH2s54bKxC_ORkcDnEQcBAf1wanJGdDgxltvMc
这样的文件
如果没意外,会生成portainer.cuiwei.net.key
,portainer.cuiwei.net.cer
文件,个人习惯.cer
后缀改为.pem
,手动复制两个文件(portainer.cuiwei.net.key,portainer.cuiwei.net.pem)到指定位置,就可以使用了
不需要服务器,在本地就能生成
一、
acme.sh --issue -d m.cuiwei.net --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please
二、如上图,请将 TXT 记录添加到您的 DNS 记录中。每次更新证书时都需要执行此步骤。使用 DNS api 模式,这一步可以自动化。
三、
acme.sh --renew -d m.cuiwei.net --yes-I-know-dns-manual-mode-enough-go-ahead-please
手动复制两个文件(m.cuiwei.net.key
,m.cuiwei.net.pem
)到指定位置,就可以使用了
https://github.com/acmesh-official/acme.sh/wiki/DNS-manual-mode
https://github.com/acmesh-official/acme.sh/wiki/说明
https://github.com/acmesh-official/acme.sh/wiki/How-to-issue-a-cert
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有