fix(nextcloud): issue with self signed certificates (#2760)

This commit is contained in:
Meier Lukas
2025-04-01 22:20:45 +02:00
committed by GitHub
parent 243a97d637
commit 7f77130978
2 changed files with 18 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
import fsSync from "node:fs";
import fs from "node:fs/promises";
import { Agent } from "node:https";
import { Agent as HttpsAgent } from "node:https";
import path from "node:path";
import { rootCertificates } from "node:tls";
import axios from "axios";
@@ -70,12 +70,16 @@ export const createCertificateAgentAsync = async () => {
});
};
export const createAxiosCertificateInstanceAsync = async () => {
export const createHttpsAgentAsync = async () => {
const customCertificates = await loadCustomRootCertificatesAsync();
return new HttpsAgent({
ca: rootCertificates.concat(customCertificates.map((cert) => cert.content)),
});
};
export const createAxiosCertificateInstanceAsync = async () => {
return axios.create({
httpsAgent: new Agent({
ca: rootCertificates.concat(customCertificates.map((cert) => cert.content)),
}),
httpsAgent: await createHttpsAgentAsync(),
});
};