{"version":"2.1.333","anchor":"typed-api-error-kinds-unexpected-response-tls-cert-invalid","canonical_anchor":"typed-api-error-kinds-unexpected-response-tls-cert-invalid","heading":"Clearer errors for client certificate (mTLS) and proxy failures","tier":"notice","area":"SDK","scope":"both","heads_up":false,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.333\/e\/typed-api-error-kinds-unexpected-response-tls-cert-invalid","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.333","markdown":"### Clearer errors for client certificate (mTLS) and proxy failures\n\nClient certificate failures, bad TLS certificates, timeouts and proxy pages now get their own error kinds and more helpful messages\n\n**Unclear.** Whether `tls_cert_invalid`, `client_certificate` and `request_timeout` can actually be returned as error kinds, or are only described, is not clear.\n\n**What**\n\nmTLS (mutual TLS) is a setup where Claude Code proves who it is to a server with a client certificate file, set with `CLAUDE_CODE_CLIENT_CERT`, and a private key file, set with `CLAUDE_CODE_CLIENT_KEY`. Several failures around it now get their own messages:\n\n- When the server rejects the client certificate, Claude Code now reports a `client_certificate` error. If `CLAUDE_CODE_CLIENT_CERT` is set, the message tells you to check that the files in `CLAUDE_CODE_CLIENT_CERT` and `CLAUDE_CODE_CLIENT_KEY` exist and haven't expired. If it is not set, the message says the server needs a valid client certificate and `CLAUDE_CODE_CLIENT_CERT` isn't set.\n\n- When a connection cannot be opened (`FailedToOpenSocket`) and `CLAUDE_CODE_CLIENT_CERT` is set, the error now adds a hint that `CLAUDE_CODE_CLIENT_KEY` must match the certificate and needs the right passphrase. Before, this shared one message with `ENOTFOUND` and `EAI_AGAIN`.\n\n- The SDK's list of typed API error kinds, used by apps built on Claude Code, gains `unexpected_response`. It covers a successful reply that is not a normal message, such as a proxy's sign-in page. The description also now mentions `tls_cert_invalid`, `client_certificate` and `request_timeout`, though only `unexpected_response` was seen added to the list of allowed values.\n\n- The `client_certificate` description mentions `CLAUDE_CODE_DISABLE_MTLS_RELOAD_ON_STALE_CONNECTION`, the setting that controls whether Claude Code re-reads the certificate and key files and retries once.\n\n**Why**\n\nIf you use Claude Code behind a gateway that needs a client certificate, a failed connection now points at the likely cause instead of a generic network error. Apps built on the SDK can also tell these failures apart and handle each one.\n\n- Area: SDK\n- Names: `unexpected_response`\n- Tier: You'll notice\n- Useful: 3\/5\n- Signal: 2\/5\n- Scope: both\n- Heads-up: no"}