nodejs / nodejs/undici

fetch failed: unable to verify the first certificate

Open
#2,297 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
7.7k
Forks
880
Avg merge
2d 16h
Merged PRs (30d)
68

Description

Bug Description

I'm getting the error fetch failed: unable to verify the first certificate when providing a CA certificate to the dispatcher option. I've written the exact same procedure in the axios project and it's working as expected.

import { fetch, Agent as UndiciAgent } from "undici";

const response = await fetch(myUrl, {
  method: "POST",
  body: JSON.stringify({ endUserIp: ip }),
  dispatcher: new UndiciAgent({
    connect: {
      pfx: pfx,
      passphrase: "qwerty123",
      ca: testCA,
    },
  }),
  headers: { "Content-Type": "application/json" },
});
const client = axios.create({
  httpsAgent: new Agent({ pfx, passphrase: "qwerty123", ca: testCA }),
  headers: {
    "Content-Type": "application/json",
  },
});
const response = await client.post(myUrl, {
  endUserIp: ip,
});

Environment

Windows 11
Node v18.16.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The payload names the dispatcher option and its TLS connect settings but no source file or test. Start by reproducing the fetch example on Node v18.16.1 with the supplied pfx, passphrase, and CA, then trace the dispatcher’s certificate handling; done means the reported configuration verifies successfully and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.