免费SSL申请和自动更新

当前是在mac下操作

安装certbot

# mac下brew安装即可
brew install certbot
  • centos 安装
    centos安装文档

申请泛解析证书

sudo certbot certonly --manual --preferred-challenges=dns -d  '*.yourdomain.com'## 输出
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for *.yourdomain.com- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name:_asdfase.yourdomain.com.with the following value:
## TXT解析值
有朋自远发来 不亦乐乎## 此处提示注意验证是否已经在域名服务商配置了TXT解析
Before continuing, verify the TXT record has been deployed. Depending on the DNS
provider, this may take some time, from a few seconds to multiple minutes. You can
check if it has finished deploying with aid of online tools, such as the Google
Admin Toolbox: https://toolbox.googleapps.com/apps/dig/#TXT/txt.yourdomain.com.
Look for one or more bolded line(s) below the line ';ANSWER'. It should show the
value(s) you've just added.
'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Press Enter to Continue## 如果多次验证失败 可能有技能冷却时间 文档说是1小时An unexpected error occurred:
Error creating new order :: too many failed authorizations recently: see https://letsencrypt.org/docs/failed-validation-limit/Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/youdomain.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/yourdomain.com/privkey.pem
This certificate expires on 2024-04-22.
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.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:* Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate* Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

验证证书是否有效

在这里插入图片描述

查看证书

sudo certbot certificates## 输出Saving debug log to /var/log/letsencrypt/letsencrypt.log- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:Certificate Name: yourdomain.comoSerial Number: asdfasfasfasdfasKey Type: ECDSADomains: *.yourdomain.comExpiry Date: 2024-04-22 09:45:32+00:00 (VALID: 89 days)Certificate Path: /etc/letsencrypt/live/yourdomain.com/fullchain.pemPrivate Key Path: /etc/letsencrypt/live/yourdomain.com/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

默认3个月有效期

设置自动续期脚本

echo "0 0,12 * * * root $(command -v python3) -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo $(command -v certbot) renew - q”| sudo tee -a /etc/crontab > /dev/null
  • 命令比较简单 用chatgpt做下命令拆解注释

      这是一个shell命令,用于在Linux系统中将Certbot自动续订证书的命令添加到crontab中。具体分析如下:echo命令用于输出内容到标准输出。0 0,12 * * *部分是cron时间格式,指定了脚本运行的频率。这里表示在每天的0点和12点运行。root表示以root用户身份运行脚本。$(command -v python3)是用于获取Python3可执行文件的路径,并将其插入命令中。-c 'import random; import time; time.sleep(random.random() * 3600)'是通过Python代码实现延迟执行。这段代码会通过import random导入random模块,然后使用import time; time.sleep(random.random() * 3600)来随机延时一定时间,以避免多个服务器同时请求续订证书。sudo $(command -v certbot) renew -q是用于以root用户身份运行certbot的续订命令。-q参数表示以静默模式运行,输出更少的信息。sudo tee -a /etc/crontab > /dev/null用于将前面的命令的输出追加到/etc/crontab文件中,并将标准输出重定向到/dev/null来忽略输出。这样,命令的输出信息将不会显示在终端上。整个命令使用管道符(|)将输出传递给sudo tee命令,并将其添加到/etc/crontab文件中。通过执行这个命令,会将自动续订Certbot证书的任务添加到cron作业中,以在每天的0点和12点执行。这样就能够自动续订证书,确保证书在到期前得到更新。
    
  • 参考博客

https://ganzhixiong.com/p/95b00866/
letsencrypt官网

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

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

相关文章

四、Flask学习之JavaScript

四、Flask学习之JavaScript JavaScript,作为一种前端脚本语言,赋予网页生动的交互性和动态性。通过它,开发者能够操作DOM(文档对象模型)实现页面元素的动态改变、响应用户事件,并借助AJAX技术实现异步数据…

云计算项目五:部署数据库服务mysql |部署共享存储服务NFS | 配置网站服务

部署数据库服务mysql |部署共享存储服务NFS | 配置网站服务 案例1:配置逻辑卷步骤一:创建LV步骤二:格式化案例2:配置数据库服务器步骤一:安装软件MySQL服务软件(2台数据库服务器都要安装)步骤二:挂载lv设备步骤三:启动服务步骤四:管理员登录案例3:配置主从同步步骤一…

网工内推 | 国企、合资公司IT专员,13薪,NA以上即可

01 上海新徐汇(集团)有限公司 招聘岗位:IT运维 职责描述: 1.负责制定网络体系搭建、IP地址分配、网络拓扑图、无线网络等; 2.负责桌面运维技术支持,确保各类系统和终端设备正常工作; 3.负责弱电…

【并发编程】活锁

📝个人主页:五敷有你 🔥系列专栏:并发编程 ⛺️稳重求进,晒太阳 活锁 定义:活锁出现在两个线程互相改变对象的结束条件,最后谁也无法结束 代码示例 public class TestLiveLock {stati…

微机原理常考填空以及注意事项第(三)弹~

前面已经总结了200个常考题注意事项,可以翻阅查看。 以下仅个人总结的易错以及注意事项: 1,汇编语言源程序的基本格式: DATA SEGMENT;存放数据项的数据段 DATA ENDS EXTRA SEGMENT;存放数据项的附加段 EXTRA ENDS STACK1 SEGM…

React实现字符串首字母大写、翻转字符串、获取用户选定的文本

目录 React实现字符串首字母大写React实现翻转字符串React获取用户选定的文本 React实现字符串首字母大写 import React, { useState } from reactfunction App() {const [inputText, setInputText] useState()const [outputText, setOutputText] useState()const handleInpu…

编辑图片加文字的软件?分享4款!

在数字时代,图片和文字的结合已经成为信息传递的重要方式。为了满足广大自媒体人和内容创作者的需求,本文将为您推荐几款编辑图片加文字的软件,帮助您轻松实现创意表达。 魔法抠图大师 作为一款专业的图片编辑软件,还提供了多种编…

四、MyBatis 动态语句

本章概要 动态语句需求和简介if 和 where 标签set 标签trim 标签(了解)choose/when/otherwise 标签foreach 标签sql 片段 4.1 动态语句需求和简介 经常遇到很多按照很多查询条件进行查询的情况,比如智联招聘的职位搜索等。其中经常出现很多条件不取值的情况&#…

IDEA插件(MyBatis Log Free)

引言 在Java开发中,MyBatis 是一款广泛使用的持久层框架,它简化了SQL映射并提供了强大的数据访问能力。为了更好地调试和优化MyBatis应用中的SQL语句执行,一款名为 MyBatis Log Free 的 IntelliJ IDEA 插件应运而生。这款插件旨在帮助开发者…

STM32F407移植OpenHarmony笔记1

参考文档: OpenAtom OpenHarmonywidthdevice-width,initial-scale1.0https://docs.openharmony.cn/pages/v3.2/zh-cn/device-dev/get-code/gettools-acquire.md/ 搭建环境 安装linux系统: Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-91-generic x86_64) 下载源代码&a…

2分钟搞定《幻兽帕鲁》联机服务,真爽!

2分钟搞定《幻兽帕鲁》联机服务,真爽!教程 https://t.aliyun.com/U/DKivPS 幻兽帕鲁是Pocketpair开发的一款开放世界生存制作游戏,游戏于2024年1月18日发行抢先体验版本。游戏中,玩家可以在广阔的世界中收集神奇的生物“帕鲁”&a…

Zabbix 整合 Prometheus:案例分享与操作指南

一、简介 Zabbix 和 Prometheus 都是流行的开源监控工具,它们各自具有独特的优势。Zabbix 主要用于网络和系统监控,而 Prometheus 则专注于开源的分布式时间序列数据库。在某些场景下,将这两个工具整合在一起可以更好地发挥它们的优势&#…