#UNABLE_TO_GET_ISSUER_CERT error when connecting with mTLS

1 messages · Page 1 of 1 (latest)

clear cliff
#

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

clear cliff
round sage
#

Did you ever find a fix or workaround for this? I'm hitting the same thing

obsidian needle
#

@round sage if you can use fetch, you can do fetch(url, { tls: { rejectUnauthorized: false } })

round sage
#

I'm actually using ldapts and was specifying rejectUnauthorized: false already

glass smelt
#

Sorry for reviving this old post, but I wanna make sure: does this mean that Bun doesn't support mTLS?

obsidian needle
#

Bun very much does support mTLS. This is a node:http issue but it should work with fetch().