🐛 BUG: MTLS Certificate fetch doesn't work
Which Cloudflare product(s) does this pertain to?
Workers Runtime, Wrangler core
What version(s) of the tool(s) are you using?
^3.47.0 [Wrangler]
What version of Node are you using?
20.9.0
What operating system and version are you using?
Macos 15 (Beta)
Describe the Bug
Hi everyone, why I can't use mtls_certificates binding without --remote?
I created a brand new cf worker project with the following tutorial: https://developers.cloudflare.com/workers/get-started/guide/#1-create-a-new-worker-project I added the mtls certificate like the following tutorial: https://developers.cloudflare.com/workers/runtime-apis/bindings/mtls/#client-authentication-with-mtls
When I run the command wrangler dev the binding environment.MY_CERT is undefined.
But when I run the command with remote like wrangler dev --remote the binding starts to work.
Observed behavior
Is not possible to use mTLS binding fetch with no --remote command. This mean the binding is undefined after you register it correctly and try to use.
Expected behavior
The binding should work even if you don't use --remote command.
Steps to reproduce
- Create a brand new cf worker project with the following tutorial: https://developers.cloudflare.com/workers/get-started/guide/#1-create-a-new-worker-project
- Add the mtls certificate like the following tutorial: https://developers.cloudflare.com/workers/runtime-apis/bindings/mtls/#client-authentication-with-mtls
- Update
src/index.jsfile with the following code
export default {
async fetch(request, env, ctx): Promise<Response> {
console.log(env.MY_CERT)
return new Response('Hello World!');
},
}
- Run the command
wrangler devand you'll see env.MY_CERT isundefined - If you run the command
wrangler dev --remoteyou'll see env.MY_CERT is notundefinedand more and fetch calls will start to work
Please provide a link to a minimal reproduction
No response
Please provide any relevant error logs
No response
Unfortunately we don't support mTLS bindings in local dev yet (https://developers.cloudflare.com/workers/testing/local-development/#supported-resource-bindings-in-different-environments) We should have better warnings/errors when this happens, sorry for the trouble.
In my case also deployed fetch seems like not working and I have no idea how to debug this.