You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Limitations of bun operation in corporate networks: self-signed CA #17325
environment: self-signed certificate in corporate network
trying to do any operation via bun runtime: "bunx bun-pr 16166", "bun install" or any other, which requires tls/https operations
What is the expected behavior?
No tls/https errors: the CA is invalid
What do you see instead?
HTTPThread: the CA is invalid
Additional information
Only exception is "bun install" command. For it, you can specify ca certificate for the install command via bunfig.toml. But that doesn't suit me (as a user who want adopt bun in SDLC) - I don't want to commit the certificate itself or the path to it. I don't want to be limited to the bun install command. I want to be able to set a single certificate for all operations performed through bun, like the NODE_EXTRA_CA_CERTS variable for a node. Or in other words, I want to configure my environment, via a variable once, and thus allow all bun commands to work correctly.
Right now this variable seems to work only for user code execution, but not for network operations of the bun commands themselves.
Reacted by Kuznetsov Dmitriy, Val Saven, skvortsovstepan, Arnaud Durand, meng zhao, Matthew Savage, Boris Chernysh, Alexey Dudnikov, Mattwmaster58, Håvard Anda Winninge and 4 more
Important Note:
I have tried to specify the corporate CA cert .pem file with the environment variable NODE_EXTRA_CA_CERTS but that did not work on macOS with Bun v1.3.6
Verified on main at df84f8d (Linux): NODE_EXTRA_CA_CERTS is now honored by both user-code fetch() and Bun's own HTTP thread (bun install, bunx), not just user code.
# self-signed HTTPS server on localhost
$ NODE_EXTRA_CA_CERTS=/tmp/ca.pem bun -e 'await fetch(process.env.SERVER).then(r=>console.log(r.status))'
200
$ NODE_EXTRA_CA_CERTS=/tmp/ca.pem bun install # registry = https://localhost:PORT
error: GET https://localhost:PORT/fakepkg - 404 # TLS handshake succeeded; no CA error
Without the env var both fail with DEPTH_ZERO_SELF_SIGNED_CERT. NODE_USE_SYSTEM_CA=1 / --use-system-ca is also available as an alternative for OS-keychain-installed corporate CAs.
This issue still reproduces on Bun v1.4.0 (revision 34cbb9a):
buni *1 ❯ NODE_EXTRA_CA_CERTS=/etc/ssl/certs/internal-net.crt NODE_USE_SYSTEM_CA=1 bun install
bun install v1.4.0 (34cbb9a40)
HTTPThread: the CA is invalid
buni *1 ❯ echo$?
1
buni *1 ❯ NODE_EXTRA_CA_CERTS=/etc/ssl/certs/internal-net.crt yarn install --silent --pure-lockfile
(node:15252) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
buni *1 ❯ echo$? 31s
0
Activity
anru commentedon Apr 23, 2025
This issue:
ywj929 commentedon Aug 5, 2025
This issue happened on my mac.
bun add v1.2.19 (aad3abe)
🔍 Resolving [1/1] HTTPThread: the CA is invalid
Mattwmaster58 commentedon Oct 6, 2025
Is there really 0 workarounds available for this?
🐛 fix(ci): pre-install dependencies in workflow to bypass SSL issues
KirillTregubov commentedon Jan 16, 2026
I have run into a similar issue on a corporate machine. The error I receive is
error: self signed certificate in certificate chain.I have been debugging for the last couple of hours and have discovered that the following work:
I am not sure if you need to add your corporate CA cert to your keychain. I did just in case, but when I removed it, everything still worked.
SELF_SIGNED_CERT_IN_CHAIN error when using proxyman #20001
Error whilst using @kubernetes/client-node: "Self signed certificate in certificate chain" #7332
error: SELF_SIGNED_CERT_IN_CHAIN downloading package manifest #7124
self signed certificate in certificate chain anomalyco/opencode#7073
Important Note:
I have tried to specify the corporate CA cert
.pemfile with the environment variableNODE_EXTRA_CA_CERTSbut that did not work on macOS with Bun v1.3.6index.tscontents:rbanks54 commentedon Jan 19, 2026
Setting
NODE_USE_SYSTEM_CA=1as an environment variable in Windows allowed me to get the UI to start properly as well.Thanks @KirillTregubov!!
robobun commentedon Jul 24, 2026
Fixed on main.
Verified on main at df84f8d (Linux):
NODE_EXTRA_CA_CERTSis now honored by both user-codefetch()and Bun's own HTTP thread (bun install,bunx), not just user code.Without the env var both fail with
DEPTH_ZERO_SELF_SIGNED_CERT.NODE_USE_SYSTEM_CA=1/--use-system-cais also available as an alternative for OS-keychain-installed corporate CAs.anru commentedon Aug 21, 2026
This issue still reproduces on Bun v1.4.0 (revision 34cbb9a):
yarn installstill works in this case.@robobun can you reopen this issue ?
anru commentedon Oct 20, 2026
Workaround (tested for version 1.4.3):
Without
NODE_TLS_REJECT_UNAUTHORIZED=0you will getUNABLE_TO_GET_ISSUER_CERT_LOCALLYerror.Following approach:
still not works (causing error
HTTPThread: the CA is invalid)