fix(cli): --insecure also skips TLS certificate verification#38531
Merged
Conversation
--insecure previously only allowed http:// hosts, so a self-signed https:// host (e.g. an internal Dify instance) still failed login with "self signed certificate". Extend the flag to also disable TLS verification for the session, routed through an undici Agent/ EnvHttpProxyAgent with rejectUnauthorized: false. The choice is persisted per-host (mirroring the existing scheme field) so authenticated commands after login keep working without needing --insecure again, and is cleared automatically by a subsequent secure login to the same host.
67597c6 to
2ad1962
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #38531 +/- ##
==========================================
+ Coverage 85.34% 85.39% +0.05%
==========================================
Files 5012 5169 +157
Lines 265733 270146 +4413
Branches 50513 51596 +1083
==========================================
+ Hits 226779 230684 +3905
- Misses 34506 35014 +508
Partials 4448 4448
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The insecure TLS-skip only worked under Node's fetch (used by tests),
not Bun's native fetch — what the compiled difyctl binary actually
runs on. Bun ignores undici's `dispatcher` option entirely, so
--insecure against a self-signed host still failed with "self signed
certificate" in the real binary despite passing tests.
Set Bun's own `tls: { rejectUnauthorized: false }` fetch option
alongside the existing dispatcher; each runtime ignores the option it
doesn't understand. Verified against a real self-signed server both
under Vitest and in an actual compiled Bun binary.
wylswz
reviewed
Jul 8, 2026
Committed key/cert pairs have unverifiable provenance; generate a throwaway self-signed pair via openssl in beforeAll instead.
wylswz
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves ENG-708
Summary
difyctl auth login --insecureonly allowedhttp://hosts. Against a self-signedhttps://host (e.g. an internal Dify instance) it still failed withself signed certificate.--insecurenow also skips TLS certificate verification, so it covers both "no TLS" and "untrusted cert" as one blanket flag — consistent with how--insecure/-kworks in most CLIs.http/proxy.ts: builds an undiciAgent/EnvHttpProxyAgentwithrejectUnauthorized: falsewheninsecureis setinsecure_tls, same pattern as the existingschemefield) so authenticated commands after login don't need--insecureagain — and a later secure login to the same host clears itactiveHostInfo()helperTest plan
pnpm type-check,pnpm lint:fix,pnpm test(1217 passed, 0 failed)--insecure, accepted with it