找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 31|回复: 0

通过 acme.sh 轻松申请通配符证书

[复制链接]

2

主题

0

回帖

16

积分

新手上路

积分
16
发表于 3 天前 | 显示全部楼层 |阅读模式
背景

前两年一直在使用从萌咖购买的 AlphaSSL 通配符证书,最近这两天发现萌咖已经下架了这一款证书。于是想寻找更便宜经济的通配符证书。通过查询发现,现在 ZeroSSL 已经支持了通配符证书的申请,而且现在的 acme.sh 已经能很好地实现自动化了,只需要几条命令就能轻松安装证书。

安装 acme.sh

虽然有些教程推荐使用 Docker 部署 acme.sh 脚本,但是实际测试下来,如果你的 Web 服务器也是运行在 Docker 中的话,这一个方案并不是很方便。所以还是采取普通的方式安装。

<pre class="wp-block-code" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; margin-bottom: 1rem; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; max-height: 500px; overflow: auto; padding: 0.75rem; position: relative; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); white-space: break-spaces; --tw-border-opacity: 1; line-height: 1.625; color: rgb(0, 0, 0);">
  1. #将 my@example.com 修改成自己的邮箱
  2. curl https://get.acme.sh | sh -s email=my@example.com
复制代码

目前的安装脚本已经实现了下面两个自动化:

  • 自动执行 <kbd style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; padding-left: 0.25rem; padding-right: 0.25rem; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); --tw-border-opacity: 1; line-height: 1.625;">alias acme.sh=~/.acme.sh/acme.sh,后续直接通过 <kbd style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; padding-left: 0.25rem; padding-right: 0.25rem; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); --tw-border-opacity: 1; line-height: 1.625;">acme.sh 命令调用脚本
  • 自动添加 Crontab 定时任务,不需要手动添加

在执行结束后,执行 <kbd style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; padding-left: 0.25rem; padding-right: 0.25rem; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); --tw-border-opacity: 1; line-height: 1.625;">source .bashrc 使 <kbd style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; padding-left: 0.25rem; padding-right: 0.25rem; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); --tw-border-opacity: 1; line-height: 1.625;">acme.sh 命令生效,当然如果你使用的是其它的 shell 环境,需要修改这一条指令。

获取 DNS API

acme.sh 申请通配符证书只能通过 DNS 的方式进行验证,首先需要获得域名所在 DNS 的 API 密钥/令牌。这里以 Cloudflare DNS 为例,只需要在命令行输入以下命令:

<pre class="wp-block-code" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; margin-bottom: 1rem; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; max-height: 500px; overflow: auto; padding: 0.75rem; position: relative; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); white-space: break-spaces; --tw-border-opacity: 1; line-height: 1.625; color: rgb(0, 0, 0);">
  1. export CF_Token="Y_jpG9AnfQmuX5Ss9M_qaNab6SQwme3HWXNDzRWs"
复制代码

这里使用的是 API 令牌,可以灵活限制权限以及过期时间。更多的 API 使用方法参考这一个页面

申请证书

申请证书也是一句命令的事,输入下面的命令:

<pre class="wp-block-code" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; margin-bottom: 1rem; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; max-height: 500px; overflow: auto; padding: 0.75rem; position: relative; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); white-space: break-spaces; --tw-border-opacity: 1; line-height: 1.625; color: rgb(0, 0, 0);">
  1. acme.sh --issue --dns dns_cf -d example.com -d *.example.com
复制代码

除了将 <kbd style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; padding-left: 0.25rem; padding-right: 0.25rem; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); --tw-border-opacity: 1; line-height: 1.625;">example.com 修改成自己的域名外,还需要注意你使用的 DNS 服务,如果不是 Cloudflare,还需要修改命令中的 <kbd style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; padding-left: 0.25rem; padding-right: 0.25rem; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); --tw-border-opacity: 1; line-height: 1.625;">dns_cf 字段。另外需要注意的是,如果你的域名有其它证书颁发机构的 CAA 记录,需要提前删除,或者添加 ZeroSSL 的证书颁发机构的 CAA 记录。

<pre class="wp-block-code" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; margin-bottom: 1rem; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; max-height: 500px; overflow: auto; padding: 0.75rem; position: relative; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); white-space: break-spaces; --tw-border-opacity: 1; line-height: 1.625; color: rgb(0, 0, 0);">
  1. site.com. 3600 IN CAA 0 issue "sectigo.com"
  2. site.com. 3600 IN CAA 0 issuewild "sectigo.com"
复制代码

配置 Nginx

在 Nginx 中配置 SSL 主要关注 <kbd style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; padding-left: 0.25rem; padding-right: 0.25rem; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); --tw-border-opacity: 1; line-height: 1.625;">ssl_certificate、<kbd style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; padding-left: 0.25rem; padding-right: 0.25rem; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); --tw-border-opacity: 1; line-height: 1.625;">ssl_certificate_key 两个字段,这里给出一个最简单的示例配置,实际的配置需要自行修改。

<pre class="wp-block-code" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; margin-bottom: 1rem; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; max-height: 500px; overflow: auto; padding: 0.75rem; position: relative; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); white-space: break-spaces; --tw-border-opacity: 1; line-height: 1.625; color: rgb(0, 0, 0);">
  1. server {
  2.   listen 443 ssl;
  3.   server_name localhost;
  4.   ssl_certificate /etc/nginx/conf.d/selfsigned.crt;
  5.   ssl_certificate_key /etc/nginx/conf.d/selfsigned.key;
  6.   ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  7.   ssl_ciphers HIGH:!aNULL:!MD5;
  8.   location / {
  9.     proxy_pass http://webserver:8080;
  10.   }
  11. }
复制代码

安装证书

这里使用 acme.sh 脚本中的 <kbd style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; padding-left: 0.25rem; padding-right: 0.25rem; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); --tw-border-opacity: 1; line-height: 1.625;">--install-cert 参数安装,这种方式的好处是 acme.sh 会记录下安装的参数(证书安装路径、Web 服务重启指令),不需要额外编写 shell 脚本。

<pre class="wp-block-code" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-pan-x: ; --tw-pan-y: ; --tw-pinch-zoom: ; --tw-scroll-snap-strictness: proximity; --tw-gradient-from-position: ; --tw-gradient-via-position: ; --tw-gradient-to-position: ; --tw-ordinal: ; --tw-slashed-zero: ; --tw-numeric-figure: ; --tw-numeric-spacing: ; --tw-numeric-fraction: ; --tw-ring-inset: ; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,.5); --tw-ring-offset-shadow: 0 0 #0000; --tw-ring-shadow: 0 0 #0000; --tw-shadow: 0 0 #0000; --tw-shadow-colored: 0 0 #0000; --tw-blur: ; --tw-brightness: ; --tw-contrast: ; --tw-grayscale: ; --tw-hue-rotate: ; --tw-invert: ; --tw-saturate: ; --tw-sepia: ; --tw-drop-shadow: ; --tw-backdrop-blur: ; --tw-backdrop-brightness: ; --tw-backdrop-contrast: ; --tw-backdrop-grayscale: ; --tw-backdrop-hue-rotate: ; --tw-backdrop-invert: ; --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; --tw-contain-size: ; --tw-contain-layout: ; --tw-contain-paint: ; --tw-contain-style: ; border-width: 1px; border-style: solid; border-color: rgb(148, 163, 184) rgb(148, 163, 184) rgb(100, 116, 139); border-image: initial; box-sizing: border-box; font-family: &quot;Fira Code&quot;, Consolas, &quot;Lucida Console&quot;, Monaco; font-feature-settings: normal; font-size: 0.875rem; font-variation-settings: normal; margin-bottom: 1rem; background-color: rgba(226, 232, 240, 0.75); background-image: url(&quot;data:image/svg+xml;charset=utf-8,&quot;); background-repeat: repeat; background-size: 4px 4px; max-height: 500px; overflow: auto; padding: 0.75rem; position: relative; transition-duration: 0.3s; transition-property: all; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); white-space: break-spaces; --tw-border-opacity: 1; line-height: 1.625; color: rgb(0, 0, 0);">
  1. acme.sh --install-cert -d example.com \
  2. --key-file       /path/to/keyfile/in/nginx/key.pem  \
  3. --fullchain-file /path/to/fullchain/nginx/cert.pem \
  4. --reloadcmd     "sudo nginx -s reload"
复制代码

这里的文件地址、Nginx 重启命令参考实际的系统环境给定。至此已经完成,刷新你的网站后应该就能看到新的证书已经生效了。


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|一起港湾 ( 青ICP备2025004122号-1 )

GMT+8, 2025-4-22 16:34 , Processed in 0.088811 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表