🔱: [acme] sync upgrade with 21 commits [trident-sync]

Bump v5.0.0
This commit is contained in:
xiaojunnuo
2023-01-29 15:27:11 +08:00
parent 62e3945d30
commit f64ea78c44
54 changed files with 8136 additions and 2 deletions
@@ -0,0 +1,40 @@
/**
* Get ACME certificate issuers
*/
const acme = require('./../');
const util = require('./../src/util');
const pebbleManagementUrl = process.env.ACME_PEBBLE_MANAGEMENT_URL || null;
/**
* Pebble
*/
async function getPebbleCertIssuers() {
/* Get intermediate certificate and resolve alternates */
const root = await acme.axios.get(`${pebbleManagementUrl}/intermediates/0`);
const links = util.parseLinkHeader(root.headers.link || '');
const alternates = await Promise.all(links.map(async (link) => acme.axios.get(link)));
/* Get certificate info */
const certs = [root].concat(alternates).map((c) => c.data);
const info = certs.map((c) => acme.crypto.readCertificateInfo(c));
/* Return issuers */
return info.map((i) => i.issuer.commonName);
}
/**
* Get certificate issuers
*/
module.exports = async () => {
if (pebbleManagementUrl) {
return getPebbleCertIssuers();
}
throw new Error('Unable to resolve list of certificate issuers');
};