CDNhttps 证书通过 NodeJS SDK 接口上传
Posted Rand Tsui
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CDNhttps 证书通过 NodeJS SDK 接口上传相关的知识,希望对你有一定的参考价值。
const fs = require('fs');
const Core = require('@alicloud/pop-core');
let client = new Core(
accessKeyId: 'xxxx',
accessKeySecret: 'xxxx',
endpoint: 'https://cdn.aliyuncs.com',
apiVersion: '2018-05-10'
);
//获取所有加速的域名,然后批量设置同一个证书
client.request('DescribeUserDomains', , method: 'POST' ).then(result =>
let domains = JSON.parse(JSON.stringify(result)).Domains.PageData;
let arr = [];
domains.forEach(item => arr.push(item.DomainName); );
client.request('BatchSetCdnDomainServerCertificate',
"DomainName": arr.join(','),
"SSLProtocol": "on",
"ForceSet": "1",
"SSLPub": fs.readFileSync('/etc/letsencrypt/live/cdn.randspace.xyz/fullchain.pem'),
"SSLPri": fs.readFileSync('/etc/letsencrypt/live/cdn.randspace.xyz/privkey.pem')
, method: 'POST' ).then(result2 =>
let file = '/randspace/tools/cdnCertUpload/log.txt';
fs.appendFileSync(file, new Date().toLocaleString() + '\\n');
fs.appendFileSync(file, JSON.stringify(result2) + '\\n');
);
);
GitHub - aliyun/openapi-core-nodejs-sdk: OpenAPI POP core SDK for Node.js
以上是关于CDNhttps 证书通过 NodeJS SDK 接口上传的主要内容,如果未能解决你的问题,请参考以下文章
sh 笔记:OpenSSL生成「自签名」证书,配置Nodejs本地HTTPS服务 - 11.通过v3.ext对证书进行重新生成