环境:

免费通配符HTTPS证书网址:

https://letsencrypt.org/

1.下载证书申请工具

[root@centos ~]# mkdir /opt/letsencrypt -p

[root@centos ~]# cd /opt/letsencrypt

[root@centos ~]# wget https://dl.eff.org/certbot-auto

[root@centos ~]# chmod u+x certbot-auto

2.申请证书 (注意提供的域名 *.domain.com)

[root@centos ~]# ./certbot-auto --server https://acme-v02.api.letsencrypt.org/directory --manual --preferred-challenges dns-01 certonly -d "*.domain.com"

需要下载多个依赖包,完成后,需要根据提示提供信息

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): user@mail.com

-------------------------------------------------------------------------------
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A

-------------------------------------------------------------------------------
Would you be willing 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 EFF and
our work to encrypt the web, protect its users and defend digital rights.
-------------------------------------------------------------------------------
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for jooylife.cn

-------------------------------------------------------------------------------
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.

Are you OK with your IP being logged?
-------------------------------------------------------------------------------
(Y)es/(N)o: Y

-------------------------------------------------------------------------------
Please deploy a DNS TXT record under the name
_acme-challenge.domain.com with the following value:

GcOWiMJRp7DjbG0m855SU1dWxwgL16zDiqQjOJwKNdY

Before continuing, verify the record is deployed.
-------------------------------------------------------------------------------
Press Enter to Continue

到这里,先不要继续,必须先到域名解析平台,添加DNS TXT记录

域名解析设置

记录类型:TXT
主机记录:_acme-challenge.domain.com
解析线路:
记录值:GcOWiMJRp7DjbG0m855SU1dWxwgL16zDiqQjOJwKNdY
TTL值:10分钟

设置后,需要确认更新成功 (dig命令需要安装 bind-utils)

[root@centos ~]# yum install bind-utils -y
[root@centos ~]# dig _acme-challenge.domain.com txt

如果成功读取到值,则代表设置成功

Before continuing, verify the record is deployed.
-------------------------------------------------------------------------------
Press Enter to Continue

回车继续证书生成

查看证书信息

[root@centos ~]# cd /opt/letsencrypt

[root@centos ~]# ./certbot-auto certificates

查看生成证书文件

[root@centos ~]# ll /etc/letsencrypt/live/domain.com

查看证书更新到期信息

[root@centos ~]# cat /etc/letsencrypt/renewal/domain.com.conf

复制证书到指定目录

[root@centos ~]#mkdir /data/ssl -p

[root@centos ~]#cp /etc/letsencrypt/live/domain.com/fullchain.pem /data/ssl

[root@centos ~]#cp /etc/letsencrypt/live/domain.com/privkey.pem /data/ssl

[root@centos ~]#chown -R www:www fullchain.pem

[root@centos ~]#chown -R www:www privkey.pem

设置NGINX,让网站使用https证书

[root@centos ~]#cd /opt/nginx/conf/vhosts/

[root@centos ~]#vim www.domain.com.conf

server {
    server_name www.domain.com;
    listen 443 ssl;
    ssl on;
    ssl_certificate /data/ssl/fullchain.pem;
    ssl_certificate_key /data/ssl/privkey.pem;
 
    location / {
      proxy_pass http://www.baidu.com;
    }
}

证书手动更新 (30天内到期才可以更新)

[root@centos ~] cd /opt/letsencrypt

[root@centos ~] certbot-auto renew

配置证书自动更新

[root@centos ~] cd /opt/letsencrypt

[root@centos ~] vim renew-hook.sh

#
##! /bin/bash
##

mv /data/ssl/fullchain.pem /data/ssl/fullchain.pem.old
mv /data/ssl/privkey.pem /data/ssl/privkey.pem.old
cp /etc/letsencrypt/live/domain.com/fullchain.pem /data/ssl
cp /etc/letsencrypt/live/domain.com/privkey.pem /data/ssl
chown -R www:www /data/ssl/fullchain.pem
chown -R www:www /data/ssl/privkey.pem
systemctl restart nginx
echo "At $(date +%D) $(date +%T) Finish renew https certs && restart nginx."

保存

[root@centos ~] chmod +x renew-hook.sh

[root@centos ~] crontab -e

# 每月1日的凌晨3点就会执行一次所有域名的续期操作
00 03 01 * * /opt/letsencrypt/certbot-auto renew --renew-hook "/opt/letsencrypt/renew-hook.sh" 1>>/data/crond/ntpdate.log 2>&1

*********************************************************************************************************************************************

# 每月1号5时执行执行一次更新,并重启nginx服务器
00 05 01 * * /opt/letsencrypt/certbot-auto renew ---quiet && systemctl restart nginx

#/bin/sh
#续期说明:只用renew的话,会先检查证书是否需要更新,大概是距离到期还有三天或者十几天之内才会执行更新,否则会提示不需要更新。(昨天更新了证书,今天直接用renew,提示不允许更新)
#这里方便测试,增加参数--force-renew,能够强制立即更新(但好像也会有检查,时间会变短,比如我刚才更新过了,马上再次执行会报错并提示不需要更新)。
./certbot-auto renew --force-renew

*********************************************************************************************************************************************

HTTPS性能评估网站:

https://www.ssllabs.com/ssltest/

https://www.upyun.com/https

Centos7 通配符HTTPS证书申请 实测 笔记的更多相关文章

  1. 新版startssl 免费SSL证书申请 (实测 笔记 https http2 必要条件)

    简单说明: 目前多个大型网站都实现全站HTTPS,而SSL证书是实现HTTPS的必要条件之一. StartSSL是StartCom公司旗下的.提供免费SSL证书服务并且被主流浏览器支持的免费SSL.包 ...

  2. HTTPS证书申请相关笔记

    申请免费的HTTPS证书相关资料 参考资料: HTTPS 检测 苹果ATS检测 什么是ECC证书? 渠道2: Let's Encrypt 优点 缺点 Let's Encrypt 的是否支持非80,44 ...

  3. Nginx 学习笔记(九)申请Let's Encrypt通配符HTTPS证书

    Let's Encrypt 宣布 ACME v2 正式支持通配符证书,并将继续清除 Web 上采用 HTTPS 的障碍,让每个网站轻松获取管理证书.消息一出,马上就有热心用户分享出了 Let's En ...

  4. Let's Encrypt 免费通配符 SSL 证书申请教程——但是也需要email,域名所有权等,如果是黑产用的话会这样用吗?会不会暴露自己身份???

    Let's Encrypt 免费通配符 SSL 证书申请教程 from:https://blog.csdn.net/English0523/article/details/79608464 2018 ...

  5. 项目总结20:阿里云免费https证书申请

    项目总结20:阿里云免费https证书申请 1. 登录阿里云控制台 www.aliyun.com,用账户信息登录 2. 在”产品与服务”搜索SSL,选择SSL证书 3. 点击购买证书 4. 选择” S ...

  6. linux免费https证书申请教程

    linux免费https证书申请教程直接去阿里云 菜单有个证书服务进去有个购买证书菜单 选择免费的 然后会提示写个人资料 然后系统生成csr 然后提交审核这个时候会有份邮件 文件下载上传到你的服务器 ...

  7. 申请 Let's Encrypt 通配符 HTTPS 证书

    目录 一.背景知识 1.1.什么是通配符证书 1.2.什么是 Let's Encrypt 二.证书申请(certbot) 2.1.系统确定 2.2.工具安装 2.3.证书申请 2.4.证书查看 2.5 ...

  8. https证书申请

     因为要为海外组的aws设置https证书,由于使用的是新的域名,所以要先申请购买证书,然后设置上去.由于是第一次做这件事.所以过程有些坎坷.      先购买https证书.看了几家,感觉GoDad ...

  9. 微信小程序之后台https域名绑定以及免费的https证书申请

    微信小程序在11月3号发布了,这是一个全新的生态,没有赶上微信公众号红利的开发者,运营者可别错过这趟车了. 但是微信的后台需要全https,之前我还不相信,后台注册了后进后台才发现,服务器配置如下图 ...

随机推荐

  1. android TextView加载html 过滤所有标签,保留换行标签

    情景: TextView加载后端接口获取到的html富文本 遇到的问题: 客户端通过接口取到的数据如下: <p style="margin-top: 0px; margin-botto ...

  2. oracle insert into 插入多组数据方法总结

    网上好多oracle 的文章,多是以oracle开头,内容确实其他sql,一幅气死人不偿命的嘴脸着实让人难受. 今天就更新点oracle 使用insert into插入数据的方式: 1.oracle ...

  3. 微信中音乐播放在ios不能自动播放解决

    在微信中,ios手机下面音乐被自动禁掉无法自动播放,我们可以执行触发body上的元素,自动进行播放. //音乐 var x = document.getElementById("myAudi ...

  4. redis缓存雪崩、缓存穿透、数据库和redis数据一致性

    一.缓存雪崩 回顾一下我们为什么要用缓存(Redis):减轻数据库压力或尽可能少的访问数据库. 在前面学习我们都知道Redis不可能把所有的数据都缓存起来(内存昂贵且有限),所以Redis需要对数据设 ...

  5. HDU-魔咒词典(字符串hash)

    魔咒词典 TimeLimit: 8000/5000 MS (Java/Others)  MemoryLimit: 32768/32768 K (Java/Others) 64-bit integer ...

  6. python学习记录20190121

    print 语句默认会给每一行添加一个换行符.只要在print 语句的最后添加一个逗号(,),就可以改变它这种行为 带逗号的print语句输出的元素之间会自动添加一个空格 print 没有任何参数的p ...

  7. DISPLAY变量和xhost(原创)

    DISPLAY 在Linux/Unix类操作系统上, DISPLAY用来设置将图形显示到何处. 直接登陆图形界面或者登陆命令行界面后使用startx启动图形, DISPLAY环境变量将自动设置为:0: ...

  8. knn算法详解

    邻近算法,或者说K最近邻(kNN,k-NearestNeighbor)分类算法是数据挖掘分类技术中最简单的方法之一.所谓K最近邻,就是k个最近的邻居的意思,说的是每个样本都可以用它最接近的k个邻居来代 ...

  9. .net基础学java系列(三)徘徊反思

    .net基础学java系列(三)徘徊反思 上一篇文章:.net基础学java系列(二)IDE 之 插件 这两天晚上看完了IDEA的教学视频:https://edu.51cto.com/course/1 ...

  10. FbinstTools制作多系统启动U盘(Windows+Linux)

    U盘启动盘制作工具在国内有倆工具,老毛桃.大白菜.也不知道是谁模仿谁的,反正PE肯定是Microsoft的. PE其实就是精简版的Windows维护系统,那如何制作Linux启动盘呢,百度搜“linu ...