How to fetch from an URL with a bad cert?

I have a test server provided to me that I need to communicate with during development, but it has an untrusted certificate. How do I make a request to it? Basically, I want await fetch("https://untrusted-root.badssl.com/") to work, right now the request fails with the status code 526.
8 Replies
Cyb3r-Jak3
Cyb3r-Jak312mo ago
I don’t believe this is possible with workers. Node fetch requires the use of https module to ignore ssl errors and https module doesn’t exist in workers. https://github.com/orgs/nodejs/discussions/44038
GitHub
fetch() SSL disable certificate validation · nodejs · Discussion #4...
Hello, is there any way to disable SSL certificate validation for self-signed certificates or expired ones? Thank you.
CounterCulturePhD
Maybe it's possible to add a trusted root CA for a worker?
Cyb3r-Jak3
Cyb3r-Jak312mo ago
As far as I can tell, node only lets you load a CA certificate file with an environment variable and this variable points to a certificate file. You don’t get control over the SSL certificate store for workers so you’d be unable to add it to the system
Hello, I’m Allie!
I’m wondering, does it pull from the root store? If so, you could probably add the cert there?
Cyb3r-Jak3
Cyb3r-Jak312mo ago
Locally sure
Hello, I’m Allie!
Yeah, so that would work then? Going by their message above, the insecure test server would only be used in dev anyway
Cyb3r-Jak3
Cyb3r-Jak312mo ago
Ah maybe. I read that as the non prod server is using self signed so deployed workers using that need self signed
CounterCulturePhD
Well, I would still like to run it online for staging to be as close to a prod env as possible
Want results from more Discord servers?
Add your server