I'm trying to execute an HTTPS request to a server that has a self signed TLS certificate and requires mTLS authentication.
So, I'm basically importing the https library and executing the request using an https.Agent. Since the server has a self signed TLS certificate, I'm setting the rejectUnauthorized field of the https.Agent options to false.
Here's my pseudo-code:
// index.ts
import * as https from "https";
const uri = new URL("https://server.com");
const agent = new https.Agent({
cert: // my x509 certificate
key: // my private key for the certificate
rejectUnauthorized: false,
});
const req = https.request({
hostname: uri.hostname,
port: uri.port,
path: "/path",
method: "GET",
agent: agent,
}, (res) => {
// res handling here
});
req.on("error", reject);
req.end();
});
However, the request gives me this error:
UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate
path: "https://server.com/path"
If I transpile the file to js and execute it with Node (v20), everything goes fine and the request is successfully received from the server.
This issue seems to be related: https://github.com/oven-sh/bun/issues/6520
OS: macOS 14.2.1
Bun version: 1.0.22