有用华为云的吗?我写了个 Nodejs https 证书自动更新的模块,分享一下
有用华为云的吗?我写了个 Nodejs https 证书自动更新的模块,分享一下
结合 acme.sh, jenkins 实现自动化更新证书。
目前通过 nodejs 调用华为云 api 模块已经测试完成。
acme.sh 通过 docker 部署也测试完成。
贴个博客链接: https://www.ilaipi.top/2020/03/28/acme-sh%e8%af%81%e4%b9%a6%e5%90%8c%e6%ad%a5%e5%88%b0%e5%8d%8e%e4%b8%ba%e4%ba%91/
再贴一下 GitHub 地址吧:
https://github.com/ilaipi/huawei-cloud nodejs 调用华为 api
https://github.com/ilaipi/acme.sh-docker acme 实现 docker 部署
是通过 acme.sh 的别名方式认证的吗?
#2 用的是 dns 的方式。我这边域名一直放阿里云,所以支持 dns 的
华为云搞了个很像 vscode 的 ide
基于 vscode 开发的,不是很像。
自从 vscode 提供了生态齐全有活力的浏览器 IDE 解决方案,云 IDE 自主研发速度明显加快。
#4
#5
哈哈,并没有关系。之前一直用阿里云,之所以选择华为云,是因为阿里云的负载均衡产品 slb,限制一个监听器只能配置 40 条转发规则,莫名其妙的限制。。
当然有用华为云的用户,很高兴看到你分享了Node.js HTTPS证书自动更新的模块。在云环境中,证书管理特别是自动更新是一个非常重要的功能,它能帮助我们避免证书过期导致的服务中断。以下是一个简要的代码示例,展示如何在Node.js中实现HTTPS证书自动更新,并假设你使用华为云的一些API来获取和更新证书。
const fs = require('fs');
const https = require('https');
const axios = require('axios');
const crypto = require('crypto');
// 假设你从华为云获取证书的API
async function fetchCertificateFromHuaweiCloud() {
const response = await axios.get('https://your-huaweicloud-api-endpoint/get-certificate');
return response.data; // 假设返回 {cert: '-----BEGIN CERTIFICATE-----...', key: '-----BEGIN PRIVATE KEY-----...'}
}
async function updateHttpsServer(server) {
const { cert, key } = await fetchCertificateFromHuaweiCloud();
const options = {
key: fs.readFileSync(key),
cert: fs.readFileSync(cert)
};
server.close(() => {
https.createServer(options, server.requestListener).listen(server.address().port, () => {
console.log('HTTPS server updated with new certificate');
});
});
}
// 定时更新证书
setInterval(async () => {
try {
await updateHttpsServer(yourHttpsServerInstance);
} catch (error) {
console.error('Error updating HTTPS certificate:', error);
}
}, 30 * 24 * 60 * 60 * 1000); // 每30天更新一次
注意:上述代码仅为示例,具体实现细节需要根据华为云API文档进行调整。