域名分为主域名 test.com 和泛域名 *.test.com

如果又很多子域名,每个都要配置证书

这也太麻烦了。

所以这次我们来学习 如何搞泛域名证书。

安装certbot

certbot 官方推荐的自动化脚本, 用来申请免费SSL证书的。 (certbot中文翻译是 证书机器人的意思)

centos9以前

# 安装 certbot 以及 certbot nginx 插件
yum install -y certbot python3-certbot-nginx

centos9, 有所改动

yum install -y epel-release
yum install -y certbot python3-certbot-apache

()申请证书

执行证书生成命令,

过程中根据命令提示,去云服务商后台增加一条dns,并将certbot生成的参数填写到dns配置的相关位置(不要执行一下代码)。

certbot certonly -d *.dingshaohua.com --manual --preferred-challenges dns

按照提示,在你的域名服务商处,添加对应的 DNS TXT 解析记录

为什么certbot 需要你在云服务商增加dns,还不是为了证明这个域名是你所有权的

再回车继续,证书就生成了。

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/dingshaohua.com/fullchain.pem
Key is saved at: /etc/letsencrypt/live/dingshaohua.com/privkey.pem
This certificate expires on 2024-05-01.
These files will be updated when the certificate renews. NEXT STEPS:
- This certificate will not be renewed automatically. Autorenewal of --manual certificates requires the use of an authentication hook script (--manual-auth-hook) but one was not provided. To renew this certificate, repeat this same certbot command before the certificate's expiry date.

()通配符证书只是针对二级域名

注意 Let’s encrypt通配符证书只是针对二级域名,并不能针对主域名,如*.dingshaohua.comdingshaohua.com 被认为是两个域名,在申请的时候需要注意都要申请(不用担心 生成的证书仍然只有一个 不会有几个域名就会有几个) (执行这个!!!)

certbot certonly  -d "*.dingshaohua.com" -d "dingshaohua.com" --manual --preferred-challenges dns

使用证书

首先,你需要在域名服务商处,提前配置好域名解析(这个跟证书无关,就算是http方式访问你也的配置)。

其次,在nginx配置配置,比如 我有两个域名想使用这个证书dingshaohua.coma.dingshaohua.com,那么配置如下即可

# dingshaohua.com
server {
listen 80;
server_name dingshaohua.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
# nginx使用虚拟主机来配置站点:每个虚拟主机使用server { } 来配置
# listen用来配置监听端口,server_name为虚拟主机服务名称
listen 443 ssl;
server_name dingshaohua.com; # 证书位置
ssl_certificate /etc/letsencrypt/live/dingshaohua.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dingshaohua.com/privkey.pem; #证书校验(通用)
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on; # 路由
location / {
root /home/webroot/book-ding;
try_files $uri $uri/ /index.html;
}
} # a.dingshaohua.com
server {
listen 80;
server_name a.dingshaohua.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443 ssl;
server_name a.dingshaohua.com; ssl_certificate /etc/letsencrypt/live/dingshaohua.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dingshaohua.com/privkey.pem; ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on; location / {
root /home/abc;
}
}

续签

# 根据提示处理
certbot certonly -d *.klvchen.com --manual --preferred-challenges dns
# 或
certbot renew
# 或
certbot renew --quiet

一些参考阅读

certbot命令参数含义

https://blog.csdn.net/neizhiwang/article/details/105605967

https://www.4spaces.org/217.html

https://zhuanlan.zhihu.com/p/627526278

什么是通配符证书

https://www.zhihu.com/question/602288859/answer/3109842778

证明Let’s encrypt通配符证书只是针对二级域名,并不能针对主域名

https://cloud.tencent.com/developer/article/1915432?areaId=106001

https://weibo.com/6916341052/JhAkDDNik

https://www.5288z.com/2267.html

https://blog.csdn.net/owenzhang24/article/details/122234156

Let’s Encrypt申请泛域名证书的更多相关文章

  1. Let's encrypt申请泛域名证书以及报错处理

    申请泛域名证书的步骤请参考该链接地址: https://www.jianshu.com/p/df6d13187578 报错信息: No matching distribution found for ...

  2. Let's encrypt申请泛域名证书

    1.下载工具 wget https://dl.eff.org/certbot-auto chmod a+x ./certbot-auto 2.初始化 ./certbot-auto 3.获取证书(1) ...

  3. Let's Encrypt免费泛域名证书申请

    一. 下载acme.sh,以下四条命令任选一条即可 curl https://get.acme.sh | shwget -O - https://get.acme.sh | sh curl https ...

  4. 使用 certbot 申请泛域名https证书

    使用 certbot 申请泛域名https证书 Intro Certbot 是一个基于 Let's Encrypt 的自动化申请证书的工具,支持的系统和web server也很多,详见 Certbot ...

  5. CentOS 7配置Let’s Encrypt支持免费泛域名证书

    Let’s Encrypt从2018年开始支持泛域名证书,有效期3个月,目前仅支持acme方式申请,暂不支持certbot. 1.安装acme.sh curl https://get.acme.sh ...

  6. let's encrypt部署免费泛域名证书

    环境说明 [root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) [root@localhos ...

  7. acme.sh建立SAN证书 和泛域名证书

    文件来源 https://github.com/Neilpang/acme.sh/wiki/How-to-issue-a-cert domain=$domain time=`date +%Y%m%d% ...

  8. 申请 Let’s Encrypt 泛域名证书 及 Nginx/Apache 证书配置

    什么是 Let’s Encrypt? 部署 HTTPS 网站的时候需要证书,证书由 CA (Certificate Authority )机构签发,大部分传统 CA 机构签发证书是需要收费的,这不利于 ...

  9. 基于Let's Encrypt生成免费证书-支持多域名泛域名证书

    目录 客户端 certbot acme.sh 安装acme.sh 1. 自动安装 2. 手动安装 3. 测试收否安装成功 使用acme.sh生成证书 1. HTTP 方式 2. DNS 方式 1. 生 ...

  10. 使用 acme.sh 签发续签 Let‘s Encrypt 证书 泛域名证书

    1. 安装 acme.sh 安装很简单, 一个命令: curl https://get.acme.sh | sh 并创建 一个 bash 的 alias, 方便你的使用 alias acme.sh=~ ...

随机推荐

  1. 行为识别TSM训练ucf101数据集

    序言 最近有个行为检测的需求,打算用行为识别做,纯小白入这个方向,啃了两周的TSM原理和源码,训练好自己的数据集后,发现好像没法应用到自己的需求场景??玛德!算了,还是要记录一下.原理就没别要讲了,网 ...

  2. 【杂谈】死锁?NO,时间跳跃!

    在日常开发或线上运维中,我们经常会遇到各种数据库异常,例如超时.死锁等.但有些问题,表面看似平常,背后却藏着意想不到的原因. 今天就分享一次由服务器时间跳跃引发的 MySQL 获取锁超时问题的排查过程 ...

  3. eclipse安装OpenExplorer插件--快速打开文件目录

    eclipse安装OpenExplorer插件--快速打开文件目录功能: 1.下载: github: 下载地址:https://github.com/samsonw/OpenExplorer/down ...

  4. 服务端获取实际IP工具类

    import javax.servlet.http.HttpServletRequest; import java.net.InetAddress; import java.net.UnknownHo ...

  5. ES6 Fielddata is disabled on text fields by default

    使用ES做聚合运算的时候,有时候会遇到这个错误 Fielddata is disabled on text fields by default. Set fielddata=true on [host ...

  6. sonarqube+gitlab+jenkins+maven集成搭建(三)

    安装JENKINS 关闭防火墙[root@localhost ~]# systemctl stop firewalld[root@localhost ~]# systemctl disable fir ...

  7. EFCore Study(3)——“一”对多关系的设定和插入、查找级联操作

    一.建立文章.评论类 /// <summary> /// 文章 /// </summary> public class Artitle { public int Id { ge ...

  8. IDEA在检查更新的时候报错 Connection Error Failed to load plugins from 'https://plugins.jetbrains.com/idea': org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 3; 文档中根元素前面的标记必须格式正确。

    问题: IDEA在更新的时候报错 Connection Error Failed to load plugins from 'https://plugins.jetbrains.com/idea': ...

  9. Linux 的那些操作都出自哪里?

    Linux 的那些操作都出自哪里? 可以说 Linux 是一种 Unix.Unix 有一个 man 手册,手册包含了安装的软件的使用帮助,遇到问题的解决办法.总之几乎所有的操作都是手册里面有迹可循的, ...

  10. 【记录】PR使用技巧记录

    @ 目录 [PR最重要的两个操作] 一.关键帧 1. 如何设置关键帧? 2. 应用实例 1)1s内视频从明变暗 2)1s内视频画面由大到小 二.入点.出点 [其他] PR批量调整视频效果 PR剪视频片 ...