Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
Hung-Han (Henry) Chen committed 2021-11-02 16:54:05 +02:00
1 parent ed7d9f4541
commit d0416a783f
1 file changed
+7 -4
+7 -4
View File
@@ -76,10 +76,13 @@ export function getWinRootCA(): Promise<string[]> {
* Add (or merge) CAs to https.globalAgent.options.ca
*/
export function injectCAs(CAs: string[]) {
const oldCAs = [https.globalAgent.options.ca].flat();
const injectedCAs = new Set([...oldCAs, ...CAs]);
https.globalAgent.options.ca = [...injectedCAs];
for (const cert of CAs) {
if (Array.isArray(https.globalAgent.options.ca) && !https.globalAgent.options.ca.includes(cert)) {
https.globalAgent.options.ca.push(cert);
} else {
https.globalAgent.options.ca = [cert];
}
}
}
/**