免费的https证书生成很消耗时间,godaddy 又很慢。所以做一个自动化脚本,就省力啦。

// 创建 https 证书class makeHttpsConfig {//阻塞延时static sleep(ms) {return new Promise((resolve, reject) => {setTimeout(resolve, ms);})}static invokeCmd(cmd){var exec = require('child_process').exec;var cmdStr = cmd;exec(cmdStr, function(err,stdout,stderr){if(err) {console.log('error:'+stderr);} else {console.log('invoke',cmd,'success')}});}//执行 https 证书的生成static async make(domain_name) {let spawn = require('child_process').spawn;// /root/letsencrypt/certbot-auto certonly  -d *.galaxy-in.pw --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directorylet create_cmd = spawn('/root/letsencrypt/certbot-auto', ['certonly',`-d *.${domain_name}`,'--manual','--preferred-challenges','dns','--server','https://acme-v02.api.letsencrypt.org/directory']);//配置域名let myip = 'xxxxxx';//自己的IPlet gdapikey = "key:scert";//自己配置哦makeHttpsConfig.invokeCmd(`curl -s -X PUT "https://api.godaddy.com/v1/domains/${domain_name}/records/A/*" -H "Authorization: sso-key ${gdapikey}" -H "Content-Type: application/json" -d "[{\\"data\\": \\"${myip}\\"}]"`)//配置 nginx 文件。把 template_domain.conf 文件作为模板,生成 nginx 配置文件makeHttpsConfig.invokeCmd(`sed "s/template_domain/${domain_name}/g" /www/server/panel/vhost/nginx/template_domain.conf > /www/server/panel/vhost/nginx/${domain_name}.conf`);// await makeHttpsConfig.sleep(60*1000);let step = 0;// 捕获标准输出并将其打印到控制台create_cmd.stdout.on('data', async function (data) {console.log('standard output:\n' + data);let str = '' + dataif (step == 0){if (str.indexOf("(Y)es/(N)o:") >= 0) {console.log('检测到输入的要求');await makeHttpsConfig.sleep(3*1000);create_cmd.stdin.write('y\n');console.log('已发送 y')}else if(str.indexOf('Renew & replace the cert') >= 0){await makeHttpsConfig.sleep(3*1000);create_cmd.stdin.write('2\n');console.log('已发送 2')}step = step + 1}else if(step == 1){if(str.indexOf("_acme-challenge") >= 0){let setValue = str.match("(acme-challenge.*)\n\n(.*)\n\n")[2]console.log('find need set is:',setValue)makeHttpsConfig.invokeCmd(`curl -s -X PUT "https://api.godaddy.com/v1/domains/${domain_name}/records/TXT/_acme-challenge" -H "Authorization: sso-key ${gdapikey}" -H "Content-Type: application/json" -d "[{\\"data\\": \\"${setValue}\\"}]"`)await makeHttpsConfig.sleep(5*60*1000);create_cmd.stdin.write('\n');await makeHttpsConfig.sleep(10*1000);makeHttpsConfig.invokeCmd('nginx -s reload');}step = step + 1}});// 捕获标准错误输出并将其打印到控制台create_cmd.stderr.on('data', function (data) {console.log('standard error output:\n' + data);});// 注册子进程关闭事件create_cmd.on('exit', function (code, signal) {console.log('child process eixt ,exit:' + code);});}}var arguments = require('process').argv.splice(1);
console.log(arguments)
makeHttpsConfig.make(arguments[1])module.exports = makeHttpsConfig;

godaddy域名 自动签发 letsencrypt 证书并设置到 nginx相关推荐

  1. 阿里云万网域名一键签发SSL证书 快捷申请免费SSL证书教程

    原文链接:点击打开链接     前段时间不止一个用户在开发者论坛询问阿里云的免费证书无法购买了,经过在版主群里面的讨论和实践,并不是停止提供免费的SSL证书,而是在购买云盾证书服务中,需要先选择&qu ...

  2. [图文教程]阿里云万网域名一键签发SSL证书 快捷申请免费SSL证书

    前段时间不止一个用户在开发者论坛询问阿里云的免费证书无法购买了,经过在版主群里面的讨论和实践,并不是停止提供免费的SSL证书,而是在购买云盾证书服务中,需要先选择"Symantec" ...

  3. Cert manager自动签发/更新证书

    Cert manager使用的是免费证书Let's Encrypt,并支持在证书过期时自动更新. 本文 Cert manager使用版本:v0.12.0 官方文档:https://cert-manag ...

  4. QUIC实战(三) letsencrypt证书申请和自动续期

    部署完QUIC集群之后,原来申请的https证书到期了,就尝试了下重新安装/更新证书. Let's Encrypt 是一个自动签发 https 证书的免费项目 Certbot 是 Let's Encr ...

  5. k8s1.23 使用cert-manager自动签发阿里云DNS域名证书

    环境信息: k8s:1.23.1 helm:3.8.1 已备案域名:chandz.com 一.基础环境配置 0.镜像列表 quay.io/jetstack/cert-manager-cainjecto ...

  6. Web开发必知必会,如何使用 Letsencrypt 为网站签发 HTTPS 证书提供安全支持

    在做 Web 开发中,对网站内容的基本安全加密就是使用 HTTPS,并且在一些重视安全性的软件中,HTTPS 必不可少,微信开发中配置的域名强制使用 HTTPS,parse-dashboard 的配置 ...

  7. godaddy域名修改解析服务器,GoDaddy域名解析设置(详细图解教程) URL转发

    一.Godaddy域名解析设置 1.登陆域名管理页面 首先打开Godaddy官网:,登陆自己的Godaddy账户,然后点击导航条里的Domain Manager,接着点击自己注册的域名,具体操作如下: ...

  8. godaddy域名转发(域名跳转)设置教程

    godaddy的域名跳转很多新手都不会设置,在这里用图文教程交下大家如何设置godaddy的域名转发.其实godaddy的域名跳转设置很简单,但是关键是,目前国外的域名跳转国内基本无法使用.比如说电信 ...

  9. 处理LetsEncrypt证书签发错误acme-v02.api.letsencrypt.org timeout

    现象 LetsEncrypt证书过期后,使用certbot签发证书报错: [root@my-aliyun-server bin]# sudo certbot --apache Saving debug ...

最新文章

  1. python打开界面是什么样的-python学习笔记(图形用户界面)
  2. mysql服务怎么改名字_MySQL数据库改名字
  3. 修改php.ini参数,为何建议用ini_set()代替直接修改php.ini参数
  4. kalman滤波在雷达目标跟踪中的应用_简述Automotive radar中的多目标跟踪处理
  5. STM32 寄存器库和固件库
  6. 挑战Tiktok,跨境卖家的新红利流量渠道?
  7. Asp.Net 之Jquery知识点运用
  8. 西威变频器调试软件GF-EXprss
  9. catia批量转stp文件格式_CATIA CGR格式文件转stp或igs文件 | 坐倚北风
  10. windows电脑快捷键大全 - 高手总是很酷的
  11. 系统集成项目管理之项目合同管理
  12. 上海自考02290 c++语言程序设计试卷,上海交通大学工业自动化专业自考本科招生简章...
  13. 计算机出现假桌面怎么解决办法,win10专业版系统桌面经常假死解决办法
  14. 百度秋招笔试题 原生js按键九宫格
  15. 2022学术道德与学术规范教育【研究生】SPOC课程答案
  16. 计算机分子模拟聚乙烯,高分子物理实验思考题@中科大.pdf
  17. Python使用Eel和HTML开发桌面应用
  18. UE4+手柄对应按键测试
  19. 线性空间2--子空间
  20. 网络编程和网络应用开发

热门文章

  1. docker卸载及安装
  2. ROS机器人操作系统架构图
  3. php踩过的那些坑(5)浮点数计算
  4. android如何改变系统默认横竖屏方向
  5. C#关于批量设置Excel打开打开密码的方法
  6. 互联网摸鱼日报(2023-02-21)
  7. Win7系统如何开启/关闭无线路由器SSID广播?
  8. 使用 Velocity 实现客户端和服务器端模板
  9. 【2023王道数据结构】【绪论】思维拓展-通过C++递归与非递归实现斐波那契数列C、C++完整实现(可直接运行)
  10. 【完结】MATLAB的工程应用——影像处理