【SSL】用Certbot生成免费HTTPS证书

1. 实验背景

服务器:CentOS7.x
示例域名: www.example.com
域名对应的web站点目录: /usr/local/openresty/nginx/html

2. 安装docker

# yum -y  install  yum-utils# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo # yum list docker-ce --showduplicates | sort -r# yum -y install  docker-ce-17.12.0.ce

3. 添加镜像加速仓库


#   tee /etc/docker/daemon.json <<-'EOF'
{"registry-mirrors": ["https://m3e4jmm0.mirror.aliyuncs.com"]
}
EOF
# systemctl restart docker 
# systemctl restart docker 

4. 拉取 certbot 工具镜像

#  docker  pull  certbot/certbot:v1.11.0
v1.11.0: Pulling from certbot/certbot
801bfaa63ef2: Pull complete
7678dd7631a2: Pull complete
4c6139ab40d8: Pull complete
ff5ef8cd8062: Pull complete
73dee1f700a1: Pull complete
3dfb7190edf9: Pull complete
176bf1686307: Pull complete
fe1749c3045d: Pull complete
5a79fca54080: Pull complete
e57ac51359f9: Pull complete
88988e2ba14a: Pull complete
a916063ca8d3: Pull complete
168ae0b7107a: Pull complete
d0bd333abff4: Pull complete
Digest: sha256:fecbc1f03607f961d20a6c6b0624507e42e6dea7c7f1548e2cbb8c3782b35da9
Status: Downloaded newer image for certbot/certbot:v1.11.0

5 . 测试示例域名解析

# nslookup  www.exanple.com
Server:         114.114.114.114
Address:        114.114.114.114#53Non-authoritative answer:
Name:   www.exanple.com
Address: 199.59.243.224

注意,示例域名 www.exanple.com在certbot机器上一定要解析在公网ip,而不是解析在内网ip,否则会报错无法解析:

Waiting for verification...
Challenge failed for domain www.example.com
http-01 challenge for www.example.com
Cleaning up challenges
Some challenges have failed.IMPORTANT NOTES:- The following errors were reported by the server:Domain: www.example.comType:   dnsDetail: DNS problem: query timed out looking up A forwww.example.com; DNS problem: query timed out looking up AAAA for www.example.com

6. 生成证书

#  mkdir   -p    /etc/letsencrypt# docker run -it --rm  -v  /etc/letsencrypt:/etc/letsencrypt   -v /usr/local/openresty/nginx/html:/usr/local/openresty/nginx/html  certbot/certbot:v1.11.0  certonly --webroot -w  /usr/local/openresty/nginx/html  -d  www.example.com  -m  123456789@qq.com   --agree-tosSaving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Account registered.
Requesting a certificate for www.example.com
Performing the following challenges:
http-01 challenge for www.example.com
Using the webroot path /usr/local/openresty/nginx/html for all unmatched domains.
Waiting for verification...
Cleaning up challenges
Subscribe to the EFF mailing list (email: 123456789@qq.com).IMPORTANT NOTES:- Congratulations! Your certificate and chain have been saved at:/etc/letsencrypt/live/www.example.com/fullchain.pemYour key file has been saved at:/etc/letsencrypt/live/www.example.com/privkey.pemYour certificate will expire on 2023-12-28. To obtain a new ortweaked version of this certificate in the future, simply runcertbot again. To non-interactively renew *all* of yourcertificates, run "certbot renew"- If you like Certbot, please consider supporting our work by:Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donateDonating to EFF:                    https://eff.org/donate-le

Let’s Encrypt需要验证网站的所有权才能颁发证书, 官方称之为challenge(挑战)。

生成证书期间,Certbot工具在nginx的web目录 /usr/local/openresty/nginx/html/ 下创建隐藏临时文件夹 .well-known/acme-challenge,生成一个临时随机字符串文件 CWJ_QNbAkYkivgJWUD1wxF84fIg5sGTeTy2CeWQVwlI

Certbot 会让 Let’s Encrypt 通过公网访问 http://www.example.com/.well-known/acme-challenge/CWJ_QNbAkYkivgJWUD1wxF84fIg5sGTeTy2CeWQVwlI 校验,如果文件内容对得上就签发。

证书签发完成后,Certbot 会删除该临时文件夹,所以如果要观察这个文件,需要在证书签发期间去cat一下。

#  cat /usr/local/openresty/nginx/html/.well-known/acme-challenge/CWJ_QNbAkYkivgJWUD1wxF84fIg5sGTeTy2CeWQVwlICWJ_QNbAkYkivgJWUD1wxF84fIg5sGTeTy2CeWQVwlI.sHK8K8we80hc978Nkuo1I8tCjj8VA3D87bVwb7Y8ZwM

7. 验证证书

# ll /etc/letsencrypt/live/www.example.com/
total 4.0K
lrwxrwxrwx 1 root root  41 Sep 29 09:55 cert.pem -> ../../archive/www.example.com/cert1.pem
lrwxrwxrwx 1 root root  42 Sep 29 09:55 chain.pem -> ../../archive/www.example.com/chain1.pem
lrwxrwxrwx 1 root root  46 Sep 29 09:55 fullchain.pem -> ../../archive/www.example.com/fullchain1.pem
lrwxrwxrwx 1 root root  44 Sep 29 09:55 privkey.pem -> ../../archive/www.example.com/privkey1.pem
-rw-r----- 1 root root 692 Sep 29 09:55 README

证书: /etc/letsencrypt/live/www.example.com/fullchain.pem
私钥: /etc/letsencrypt/live/www.example.com/privkey.pem

#  openssl   x509   -noout   -text  -in  /etc/letsencrypt/live/www.example.com/fullchain.pemCertificate:Data:Version: 3 (0x2)Serial Number:03:bb:52:8d:5a:6f:03:cc:f1:06:12:75:b0:2f:1e:8a:e6:12Signature Algorithm: sha256WithRSAEncryptionIssuer: C=US, O=Let's Encrypt, CN=R3ValidityNot Before: Sep 29 00:55:29 2023 GMTNot After : Dec 28 00:55:28 2023 GMTSubject: CN=www.example.comSubject Public Key Info:Public Key Algorithm: rsaEncryptionPublic-Key: (2048 bit)Modulus:00:c2:d4:38:10:96:f9:7a:ef:10:00:98:1d:a3:ed:c8:96:71:60:02:ed:8d:32:99:0e:15:11:a4:14:e1:32:c8:31:75:fa:90:b2:55:3e:c1:6a:2a:f6:3f:ac:62:1b:f8:cc:0e:bc:4a:27:ea:94:2b:eb:78:49:d1:f9:c4:5e:f0:12:7f:c5:95:0d:cc:31:b3:8e:f0:ec:3e:55:b6:97:17:b0:0d:32:35:72:1a:82:87:4f:81:a0:07:60:7b:b8:03:2e:75:e8:7a:3b:1d:69:40:04:de:50:36:e8:49:b9:82:25:1d:30:3d:38:16:28:ad:df:a3:c8:d1:80:a6:87:45:e9:6a:2c:75:5b:06:0f:97:1e:15:d2:f9:c9:59:9a:9e:ee:5a:4f:bd:14:74:36:d1:4b:47:0b:c5:8d:75:b7:e7:e0:53:28:41:1f:b7:05:ae:2f:29:86:98:6f:75:64:e7:83:fd:ce:12:e2:fc:12:5d:01:01:18:e6:74:1f:83:6a:58:21:01:99:68:62:8c:29:82:7e:6e:ad:26:50:6b:5d:70:73:21:5e:19:e1:0c:35:71:53:b7:de:21:66:6e:e4:d9:32:5e:14:0c:24:2a:00:63:f9:8b:b7:84:12:28:1d:90:99:4b:08:bc:82:f8:15:68:9d:64:09:ea:1f:bf:97:3fExponent: 65537 (0x10001)X509v3 extensions:X509v3 Key Usage: criticalDigital Signature, Key EnciphermentX509v3 Extended Key Usage:TLS Web Server Authentication, TLS Web Client AuthenticationX509v3 Basic Constraints: criticalCA:FALSEX509v3 Subject Key Identifier:9F:7A:1C:81:35:31:13:62:6E:F6:84:CB:5D:67:2A:41:A5:1C:6F:ACX509v3 Authority Key Identifier:keyid:14:2E:B3:17:B7:58:56:CB:AE:50:09:40:E6:1F:AF:9D:8B:14:C2:C6Authority Information Access:OCSP - URI:http://r3.o.lencr.orgCA Issuers - URI:http://r3.i.lencr.org/X509v3 Subject Alternative Name:DNS:www.example.comX509v3 Certificate Policies:Policy: 2.23.140.1.2.1CT Precertificate SCTs:Signed Certificate Timestamp:Version   : v1(0)Log ID    : B7:3E:FB:24:DF:9C:4D:BA:75:F2:39:C5:BA:58:F4:6C:5D:FC:42:CF:7A:9F:35:C4:9E:1D:09:81:25:ED:B4:99Timestamp : Sep 29 01:55:29.732 2023 GMTExtensions: noneSignature : ecdsa-with-SHA25630:45:02:20:04:02:FF:43:4D:F2:B4:EA:9F:A0:22:F7:5A:C6:81:48:C2:A2:91:FE:5C:D7:3D:19:8D:6E:58:64:06:20:6E:4C:02:21:00:E0:AB:A8:2F:FD:D6:58:E1:62:6F:A6:94:F3:D8:5D:02:5E:52:1E:00:06:BD:58:B5:00:F5:8A:C1:7C:EB:33:B5Signed Certificate Timestamp:Version   : v1(0)Log ID    : E8:3E:D0:DA:3E:F5:06:35:32:E7:57:28:BC:89:6B:C9:03:D3:CB:D1:11:6B:EC:EB:69:E1:77:7D:6D:06:BD:6ETimestamp : Sep 29 01:55:29.706 2023 GMTExtensions: noneSignature : ecdsa-with-SHA25630:45:02:21:00:CE:03:25:26:CF:0E:65:22:9B:9E:EF:41:CE:6E:AD:EF:FE:B9:FB:66:4F:D9:0A:40:EE:A4:48:C5:1D:2A:DD:98:02:20:55:84:8F:49:51:E7:47:B7:46:A4:09:AB:C2:54:F1:65:79:67:C3:7F:DE:6B:9F:77:96:CF:81:A4:0D:F1:A1:8FSignature Algorithm: sha256WithRSAEncryption2d:c1:21:8b:3e:68:d8:df:47:bd:2e:b9:50:ea:cb:23:8d:ba:ea:17:09:15:27:cb:74:6d:6b:83:9e:a8:19:e3:75:6a:e4:ac:d2:13:6c:a0:d7:b1:2f:63:f4:f4:6f:86:51:af:37:8f:04:63:7b:6b:df:93:87:56:a2:0a:1a:79:df:f5:9d:a8:2e:45:7f:83:3e:b7:d8:a5:5e:59:c3:27:b7:9f:59:24:bc:d5:22:05:db:84:8e:db:0f:c3:1b:50:d6:c2:3e:38:8c:6e:99:29:bf:42:f7:b2:52:36:91:58:6e:fc:cf:ef:dd:ef:45:4c:9c:b9:9e:bb:53:49:a1:98:7a:ce:3b:c2:dd:38:06:c5:45:06:74:1e:da:5b:30:43:1a:82:95:ff:2c:d0:aa:f2:96:a3:0d:50:90:d1:ec:2b:9e:a9:22:3a:0e:93:9a:5c:ce:4f:c8:74:e3:c0:37:cc:4d:6f:48:3f:aa:6e:11:2c:79:3b:ce:b9:30:13:78:96:e7:ce:89:c6:d4:63:7d:3a:97:83:97:f3:a6:f0:a5:46:6a:90:4e:cf:eb:c0:13:7e:a9:01:bd:a9:b8:e1:01:2f:21:84:6c:9b:0c:b3:48:9b:48:a9:5b:b6:e3:48:91:68:56:fa:3a:26:92:88:51:c8:a8:84:17:52:45:d9:77:6d

https://myssl.com/cert_decode.html

image.png

image.png

8. 参考

Linux上 基于x86 和 arm CPU架构安装 docker
https://www.jianshu.com/p/99373f14b990

CentOS7.x cerbot 安装使用
https://www.jianshu.com/p/735ed33feaa3

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/90940.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Nginx30】Nginx学习:代理模块(四)响应头与SSL

Nginx学习&#xff1a;代理模块&#xff08;四&#xff09;响应头与SSL 响应头相关的配置也和我们之前在 FastCGI 系列学过的响应头配置是类似的&#xff0c;这一块也比较简单。而另一部分则是 Proxy 模块另一个特有的功能&#xff0c;SSL 相关的配置。不过这一块吧&#xff0c…

web:[极客大挑战 2019]LoveSQL

题目 打开页面显示如下 查看源代码&#xff0c;查到一个check.php&#xff0c;还是get传参 尝试账号密码输入 题目名为sql&#xff0c;用万能密码 1or 11# 或 admin or 11 给了一段乱码&#xff0c;也不是flag 查看字段数 /check.php?usernameadmin order by 3%23&pass…

Codeforces Round 870 (Div. 2)C. Dreaming of Freedom(数论、约数)

C. Dreaming of Freedom 题意&#xff1a;给定n个程序员&#xff0c;m个算法&#xff0c;每个人只能为一个算法投票&#xff0c;经过每轮投票后都只留下得票最高的程序&#xff0c;问最后会不会陷入循环&#xff0c;即出现几个程序平票的情况。 思路&#xff1a;我们考虑题目中…

Word | 简单可操作的快捷公式编号、右对齐和引用方法

1. 问题描述 在理工科论文的写作中&#xff0c;涉及到大量的公式输入&#xff0c;我们希望能够按照章节为公式进行编号&#xff0c;并且实现公式居中&#xff0c;编号右对齐的效果。网上有各种各样的方法来实现&#xff0c;操作繁琐和简单的混在一起&#xff0c;让没有接触过公…

Redis学习笔记(常用数据类型,发布订阅,事务和锁机制,持久化,集群,雪崩,缓存击穿,分布式锁)

一、NoSQL数据库简介 解决扩展性问题&#xff0c;如果需要对功能进行改变&#xff08;比如增删功能&#xff09;&#xff0c;用框架有一定的规范要求&#xff0c;无形中解决了扩展性问题。 Redis是一种典型的NoSQL数据库。 NoSQL的基础作用&#xff1a; 1. nginx负载均衡反向…

深度学习概念——端对端

目录 1、端对端是什么2、端对端有什么用3、例子4、引用 在读论文的过程中反复遇到端对端的概念&#xff0c;就需要理解深刻一些。在此将收集到的一些资料拿出来辅以自己的拙见&#xff0c;请大家多多批评指正&#xff01; 1、端对端是什么 在计算机学科中有一种算法叫分治法&a…

Armv9读取cache内容:Direct access to internal memory

10 访问cache Cortex-A720核心提供一种机制,通过IMPLEMENTATION DEFINED系统寄存器可以读取L1缓存、L2缓存和Translation Lookaside Buffer(TLB)。当缓存数据与系统内存数据之间的一致性异常时,您可以使用此机制来调查任何问题。 只有在EL3中才可以访问内部内存(cache)。…

排序:最佳归并树(优化外部排序中对磁盘的读写次数)

1.归并树的性质 每个初始归并段对应一个叶子结点&#xff0c;把归并段的块数作为叶子的权值归并树的WPL树中所有叶结点的带权路径长度之和归并过程中的磁盘I/O次数归并树的WPL*2 如下图&#xff1a; 每个初始归并段看作一个叶子结点&#xff0c;归并段的长度作为结点权值&a…

【深度学习】分类问题探究(多标签分类转为多个二分类,等)

【深度学习】分类问题探究&#xff08;多标签分类转为多个二分类&#xff0c;等&#xff09; 文章目录 【深度学习】分类问题探究&#xff08;多标签分类转为多个二分类&#xff0c;等&#xff09;1. 介绍2. 一些解析2.1 关于多标签分类 to 多个二分类 2.2 continue 1. 介绍 在…

有车型(CarModel),车厂(CarFactory),经销商(Distributor)三个表

用drf编写 1 有车型(CarModel)&#xff0c;车厂&#xff08;CarFactory&#xff09;&#xff0c;经销商(Distributor)三个表, 一个车厂可以生产多种车型&#xff0c;一个经销商可以出售多种车型&#xff0c;一个车型可以有多个经销商出售车型&#xff1a;车型名&#xff0c;车型…

FFmpeg视音频分离器----向雷神学习

雷神博客地址&#xff1a;https://blog.csdn.net/leixiaohua1020/article/details/39767055 本程序可以将封装格式中的视频码流数据和音频码流数据分离出来。 在该例子中&#xff0c; 将FLV的文件分离得到H.264视频码流文件和MP3 音频码流文件。 注意&#xff1a; 这个是简化版…

C/C++进程线程超详细详解

目录 前言 一、进程基础 1.进程概念 2.进程特征 3.进程状态&#xff08;如图清晰可见&#xff09; 4&#xff0c;进程的标识 实例代码如下&#xff1a; 5.进程的种类 实例shell脚本程序如下: 二、进程API 1.创建子进程 实例代码如下&#xff1a; 2.exec函数族 函数…

搭建自己的pypi服务器

要搭建自己的 PyPI 服务器&#xff0c;您可以使用 warehouse 项目&#xff0c;它是 PyPI 的开源实现。下面是一些基本步骤&#xff1a; 准备环境&#xff1a; 安装 Python安装 PostgreSQL 数据库 克隆 warehouse 项目&#xff1a; git clone https://github.com/pypa/wareh…

Socket网络编程练习题四:客户端上传文件(多线程版)

题目 想要服务器不停止&#xff0c;能接收很多客户上传的图片&#xff1f; 解决方案 可以使用循环或者多线程 但是循环不合理&#xff0c;最优解法是&#xff08;循环多线程&#xff09;改写 代码实战 客户端代码 package com.heima;import java.io.*; import java.net.S…

在Windows11上安装ubuntu虚拟机

一开始是参考了 VMware17虚拟机安装Ubuntu最新版本(Ubuntu22.04LTS)详细步骤 专栏的1和2来的。但是后面总是提示operating system not found&#xff0c;就参考vmware安装ubuntu时总是提示operating system not found&#xff0c;选择典型安装而不是专栏选择的自定义安装&#…

深度学习算法在工业视觉落地的思考

0.废话 距离上次的栈板识别的思考已经过去3个月&#xff0c;中间根据客户的需求和自己的思考&#xff0c;对软件又重新做了调整。但是整体上还是不满意。 0.1 老生常谈的工业视觉落地架构 对于软件架构&#xff0c;我实在没有太多的参考。没办法&#xff0c;公司根本不关心软…

Redis与Mybatis

作者在学习Redis整合时使用JDBC与Jedis&#xff0c;但是呢&#xff0c;现如今的环境下&#xff0c;Mybatis系列ORM框架是更受关注的方法&#xff0c;作者有一点点Mybatis基础&#xff0c;Mybatisplus几乎忘的差不多了&#xff0c;现对Redis整合Mybatis相关知识进行梳理&#xf…

使用华为eNSP组网试验⑵-通过端口地址进行静态路由

有了网络模拟器可以对很多网络应用场景进行模拟&#xff0c;既方便学习又有利于实际的网络实施。 之前因为没有用过&#xff0c;用过了才知道eNSP的好处。但是与思科模拟器不同&#xff0c;连接是自动连接&#xff0c;不能确定端口&#xff0c;比如使用指定的光纤端口或者RJ45的…

CSS详细基础(六)边框样式

本期是CSS基础的最后一篇~ 目录 一.border属性 二.边框属性复合写法 三.CSS修改表格标签 四.内边距属性 五.外边距属性 六.其他杂例 1.盒子元素水平居中 2.清除网页内外元素边距 3.外边距的合并与塌陷 4.padding不会撑大盒子的情况 七.综合案例——新浪导航栏仿真 …

在 msys2/mingw 下安装及编译 opencv

最简单就是直接安装 pacman -S mingw-w64-x86_64-opencv 以下记录一下编译的过程 1. 安装编译工具及第三方库 pacman -S --needed base-devel mingw-w64-x86_64-toolchain unzip gccpacman -S python mingw-w64-x86_64-python2 mingw-w64-x86_64-gtk3 mingw-w64-x86_64-…