fetch failed: unable to verify the first certificate
Open
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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