Cloudflare Workers Fetch API with Client Certificate and Private Key

I tried to inject client certificate and private key as part of options to make a call from Client Workers fetch to where it will only accept connections with valid client certificate. The response status of the call returned 403 error.

I tried the same piece of code from node js in my laptop and it works.

Here’s my code excerpt in Workers:

// I stored the cert and private key in KV

const certificate = await KV_APP_SETTINGS.get(`CLIENT_TO_SCANNER_CERT`)


const options = {

  cert: certificate,

  key: privateKey,

  keepAlive: true


const sslConfiguredAgent = new https.Agent(options);

var url = '';

const response = await fetch(url, {
  agent: sslConfiguredAgent, 

const responseBody = response.status;

console.log(responseBody); // now it returned 403

May I know how to make it work?

Cloudflare Workers does not run NodeJS. The Fetch API found in Workers is more akin to the one found in browser JS. You cannot use a client certificate with requests from Workers at the moment.

I hope this helps - even if it is not the answer you were looking for :slightly_smiling_face:

Ok well noted. Thanks for your info!