Repository navigation
Description
Description
In our company, we are using an proxy which "opens" TLS enrcyption with outside of our network for DPI. This proxy issues certificates using an internal PKI. Our internal LLM models also use certificates from our internal PKI. I am running opencode in the version 1.2.24 using Node 24.14.0 on Windows 11. I have set the environment variable NODE_EXTRA_CA_CERTS pointing to a file which contains the root certificate of our internal PKI in PEM format. The certificate is valid (today is between notBefore/notAfter).
The problem:
whenever I try to use any model (internal and external) I get the error message "certificate has expired" (which definitely is wrong, any error message regarding a self-signed certificate would be correct - assuming the environment variable is ignored or our root certificate has a problem).
Steps to identify the problem:
- Exception of external URLs of some models from SSL Decryption: these URLs work, the internal URL does not work
- Set NODE_TLS_REJECT_UNAUTHORIZED to 0: everything works as expected - apart from having a security issue
- Run simple programs in Node which only access these URLs: NODE_EXTRA_CA_CERTS is used, and everything works. Without NODE_EXTRA_CA_CERTS, I get the expected error message about self-signed certificates
- Run opencode in a container on the windows machine - everything works as expected.
- Tried the same setup in Node-Versions 20, 21 and 25
This points to a problem of the opencode-code in combination with Node for Windows. According to Copilot, Node for Windows seems to be a bit sensitive and ignores at least TLS-related environment variables, if:
- if the app overwrites https.globalAgent.options.ca
- if a package like axios, request, node-fetch, got replaces agents internally
- if the application is using tls.createSecureContext() directly
I did look at the other cases, the search has returned, but setting NODE_TLS_REJECT_UNAUTHORIZED to 0 is not a solution. Excluding URLs from SSL decryption is a workaround, but not a solution. The same is true for replacing the internal certificates for our internal models with certificates from public CAs.
Plugins
No response
OpenCode version
1.2.24
Steps to reproduce
- open Powershell (or command)
- set the environment variable NODE_EXTRA_CA_CERTS to the complete path of the internal root certificate
- start opencode
- select any model
- enter "hi" or anything
Screenshot and/or share link
No response
Operating System
Windows 11
Terminal
Windows Terminal
Activity
github-actions commentedon Mar 16, 2026
This issue might be related to an existing issue. Please check:
NODE_TLS_REJECT_UNAUTHORIZED=0workaround — though that issue is specifically aboutSSL_CERT_FILErather thanNODE_EXTRA_CA_CERTS.watashi93 commentedon Mar 16, 2026
The case #3130 is very similar indeed. The big difference is, that our problem seems to be Windows-related. We don't have any problems on Linux. Unfortunately, Windows is our desktop OS.
BTW, the solution the user okimanedeep mentioned definitively does not work for us.
cargocultprogramming commentedon Jun 9, 2026
I can confirm a similar issue on wsl (in win11). I've set up the (company-self-signed) certs in wsl manually and they work just fine. However opencode does not pick them up (returns with error: Self signed certificate in certificate chain) and setting
NODE_EXTRA_CA_CERTS,NODE_USE_SYSTEM_CAor trying to pass these asNODE_OPTIONSdoesn't help unfortunately.The only way I can work around this problem is to set
NODE_TLS_REJECT_UNAUTHORIZED=0which is not ideal.I have no issues whatsoever with other certificates (non-self-signed), when connecting to external providers. However this prevents me from connecting securely to a local endpoint that I'd like to use.
KSCGM commentedon Aug 5, 2026
Update: The issue described below is solved, a second certificate was missing.
I have the same setup on my company machine: WSL in Windows 11 with self signed certificate, that works fine otherwise.
Also I have the exact same error: "self signed certificate in certificate chain"
The only way I found to make it work is also to set
NODE_TLS_REJECT_UNAUTHORIZED=0, which is not a solution I can use.All other env vars I have tried (
NODE_EXTRA_CA_CERTS,SSL_CERT_FILE,SSL_CERT_DIR,BUN_OPTIONS="--use-system-ca",NODE_OPTIONS="--use-system-ca") did not work, no matter if I set them in the terminal, via.bashrcor/etc/environment.From log:
t-huebner-id commentedon Aug 6, 2026
I was able to fix this locally following the workaround reported in anthropics/claude-code#71554.
If you're encountering this on Windows:
certlm.msc(Win + R).Once removed, it worked immediately without restarting.
nodje commentedon Sep 7, 2026
I have the same issue on Linux TUI 1.18.18
kat-japan commentedon Sep 8, 2026
Notice: This document was created by Claude Opus.
We hit this exact symptom on Windows in an opencode-based desktop app (OpenWork), and found a cause that would explain getting "certificate has expired" for a certificate that is perfectly valid. Posting it here in case it saves someone else the day it cost us.
(The code snippets below are from that app's Electron main process rather than opencode itself, but the failure mode applies to any design that injects the Windows certificate stores as trust anchors, so it may well be the same thing you are seeing.)
What was actually wrong
The app collects certificates from the Windows stores and installs them as trust anchors:
and the Windows collection step enumerates four stores:
Two things go wrong there:
Cert:\*\CAis not a trust store. On Windows that is Intermediate Certification Authorities, a cache that Windows fills automatically from AIA fetches while you browse. Nobody ever decided to trust its contents as anchors. Node's own--use-system-cadeliberately does not read it on Windows (--use-system-casupport for intermediate certificates on Windows nodejs/node#57163).The combination is fatal. Our
CurrentUser\CAhappened to hold an old cross-signedCN=ISRG Root X2(issuerISRG Root X1, expired 2025-09-16). Node's default list contains the valid self-signedCN=ISRG Root X2(good until 2040). Same Subject, both installed as anchors, so OpenSSL builds the path into the expired one and stops. Same shape as the DST Root CA X3 breakage in 2021.That explains the confusing parts of this issue:
nodeworks, because it never loads that cacheNODE_EXTRA_CA_CERTSlooks "ignored" -- nothing is missing from the trust set, something poisonous was added to it, so adding one more certificate cannot helpNODE_TLS_REJECT_UNAUTHORIZED=0"fixes" it, because it stops path building from mattering at allHow we confirmed it
We rebuilt the trust set four different ways inside the app's own Node runtime and fetched the same HTTPS endpoint each time:
Workaround, if anyone else is stuck
List expired certificates sitting in the intermediate cache:
Back one up and remove it, then restart the app so its CA bundle is regenerated:
Removing that single certificate fixed everything for us.
What we would like to see, longer term
Ideally the Windows path would get the same treatment the macOS path already has. The macOS code restricts itself to admin-controlled keychains, with this reasoning in a comment:
That is exactly the right instinct, and it is missing on Windows:
Cert:\CurrentUser\CAis user-writable, needs no elevation, and grows on its own as you browse. Concretely, mirroring the macOS approach would mean:RootandAuthRoot, notCA(if intermediates are wanted for chain completion, keep them in a separate list and never install them as anchors)notAfteris already in the past before injecting itSharing this in good faith because the symptom is genuinely hard to track down -- there is no need to reply on my account, and please feel free to close this or move it wherever it belongs.
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊