Use ca/cert/key with Cloudflare Worker

I have a request that requires a cert - after trying it - I'm only getting 526 back. And it looks like certs are not supported in https (and the documentation backs that up https://developers.cloudflare.com/workers/runtime-apis/nodejs/https/)
// index.ts
import nodeFetch from 'node-fetch'
import https from 'node:https'
// ...
const agent = new https.Agent({
cert: env.tls_cert,
key: env.tls_key,
ca: env.ca_cert,
rejectUnauthorized: false,
})
//..
const req = await nodeFetch(lokiServer, {
agent: agent,
body: JSON.stringify(payload),
method: 'POST',
headers: { 'Content-Type': 'application/json' }
})
// index.ts
import nodeFetch from 'node-fetch'
import https from 'node:https'
// ...
const agent = new https.Agent({
cert: env.tls_cert,
key: env.tls_key,
ca: env.ca_cert,
rejectUnauthorized: false,
})
//..
const req = await nodeFetch(lokiServer, {
agent: agent,
body: JSON.stringify(payload),
method: 'POST',
headers: { 'Content-Type': 'application/json' }
})
{
// ...
"compatibility_flags": [
"nodejs_compat",
"enable_nodejs_http_modules",
"enable_nodejs_http_server_modules"
],
}
{
// ...
"compatibility_flags": [
"nodejs_compat",
"enable_nodejs_http_modules",
"enable_nodejs_http_server_modules"
],
}
How can I make requests work that need a cert? Not tied to any library or approach - just want a small thing working 🙂 Thanks so much!
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?