警告:按照本文操作可能会出现服务中断,在操作之前一定要考虑清楚。

Cloudflare 切换 SSL 证书品牌

#切换之前先点击禁用通用SSL 切换完再开启 CA可选DigiCert、Google、Let's Encrypt或Sectigo
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/[ZONE ID]/ssl/universal/settings" \
-H "Content-Type: application/json" \
-H "X-Auth-Email: [EMAIL ADDRESS]" \
-H "X-Auth-Key: [GLOBAL API KEY]" \
--data '{"certificate_authority": "digicert or google or lets_encrypt or sectigo"}'

#切换Sectigo会提示"You do not have the entitlements to switch to sectigo"

Certificate authorities
Cloudflare may issue certificates for SSL products from any of the following Certificate Authorities (CAs):

DigiCert
GlobalSign
Let’s Encrypt
Google Trust Services
Sectigo (formerly Comodo)

 

 

为什么要切换Cloudflare边缘证书?

由于使用CNAME接入Cloudflare,有两个域名是使用的Let’s Encrypt,但发现一些问题:

因为只有3个月有效期,需要经常更换证书。
由于Cloudflare或Let’s Encrypt更改政策需要TXT验证。

于此产生更换一年证书的想法。

具体操作

前期准备

需要在Cloudflare上获取对应的域名区域 ID和账户Global API Key密钥

代码

curl -X PATCH "https://api.cloudflare.com/client/v4/zones/域名区域ID/ssl/universal/settings" \
-H "Content-Type: application/json" \
-H "X-Auth-Email: 账户邮箱" \
-H "X-Auth-Key: Global API Key密钥" \
--data '{"certificate_authority": "digicert"}'

digicert:要申请的证书名称,还可以替换为sectigo(提示无权限)和lets_encrypt。

后续操作

将上面代码修改并执行后,就可以使用新证书了。在设置新的子域名前要先开启“禁用通用 SSL”, 否则还会使用Let’s Encrypt,在等待1~2分钟再关闭“禁用通用 SSL”,就可以使用新的证书了。

注意事项

在证验证时,可能会出现验证错误,可以先将域名NS设置为Cloudflare的,在证书申请完成后再改回自用的。

 

www.itansuo.info/627

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。