Repository navigation
feat(desktop): add per-connection CA trust #2964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
a80ca8e
9fd8b4e
37d42db
5a23f66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,11 @@ import { contractSha256 } from "../generated/operations"; | |
| import { desktopApi } from "../shared/ipc"; | ||
| import { messages, type Language } from "./messages"; | ||
| import { activeCheckReport, refreshConnectionState } from "./context"; | ||
| import { connectionError, connectionMessages } from "./connection-messages"; | ||
| import { | ||
| connectionError, | ||
| connectionErrorCode, | ||
| connectionMessages, | ||
| } from "./connection-messages"; | ||
| import { PageFeedback } from "@/components/ui/feedback"; | ||
| import { | ||
| Dialog, | ||
|
|
@@ -57,6 +61,7 @@ import { Button } from "@/components/ui/button"; | |
| import { PageActionButton } from "@/components/ui/page-action-button"; | ||
| import { ActionNotification } from "@/components/ui/action-notification"; | ||
| import { Input } from "@/components/ui/input"; | ||
| import { Textarea } from "@/components/ui/textarea"; | ||
| import { | ||
| Select, | ||
| SelectContent, | ||
|
|
@@ -68,6 +73,7 @@ import { | |
| Bot, | ||
| CircleCheck, | ||
| Check, | ||
| ChevronDown, | ||
| Copy, | ||
| Eye, | ||
| EyeOff, | ||
|
|
@@ -801,10 +807,18 @@ export function QuickConnectDialog({ | |
| const [storage, setStorage] = useState<StorageChoice>("persistent"); | ||
| const [savedProfile, setSavedProfile] = useState<ProfileView | null>(null); | ||
| const [credentialVisible, setCredentialVisible] = useState(false); | ||
| const [advancedOpen, setAdvancedOpen] = useState(false); | ||
| const [caPem, setCaPem] = useState(""); | ||
| const [submitted, setSubmitted] = useState(false); | ||
| const zh = language === "zh"; | ||
| const t = connectionMessages[language]; | ||
| const dialogTitle = title ?? (zh ? "连接服务" : "Connect service"); | ||
| const supportsCustomCa = | ||
| !preview && endpoint.trim().toLowerCase().startsWith("https://"); | ||
| const certificateError = | ||
| supportsCustomCa && | ||
| advancedOpen && | ||
| connectionErrorCode(error) === "invalid_certificate"; | ||
| const duplicate = state?.profiles.some( | ||
| (profile) => | ||
| profile.id !== savedProfile?.id && profile.name.trim() === name.trim(), | ||
|
|
@@ -863,7 +877,7 @@ export function QuickConnectDialog({ | |
| name: name.trim(), | ||
| endpoint: endpoint.trim(), | ||
| authentication, | ||
| caPem: null, | ||
| caPem: supportsCustomCa && caPem.trim() ? caPem : null, | ||
| compatibility, | ||
| keepCredential: false, | ||
| credential: requiresCredential ? { secret: credential, storage } : null, | ||
|
|
@@ -874,21 +888,26 @@ export function QuickConnectDialog({ | |
| if (!profile) throw { code: "not_found" }; | ||
| setSavedProfile(profile); | ||
| const checked = await desktopApi.check(profile.id, true); | ||
| if ( | ||
| checked.active?.connectionId !== profile.id || | ||
| !checked.active.report.compatibilityVerified | ||
| ) | ||
| const active = checked.active; | ||
| if (active?.connectionId !== profile.id) | ||
| throw { code: "compatibility_unverified" }; | ||
| const defaultScope = await desktopApi.defaultScope( | ||
| checked.active.generation, | ||
| ); | ||
| if (!active.report.compatibilityVerified) { | ||
| const failure = active.report.liveness.error; | ||
| throw failure?.code === "tls" | ||
| ? failure | ||
| : { code: "compatibility_unverified" }; | ||
| } | ||
| const defaultScope = await desktopApi.defaultScope(active.generation); | ||
| const selected = await desktopApi.selectScope( | ||
| checked.active.generation, | ||
| active.generation, | ||
| defaultScope.scope_id, | ||
| ); | ||
| onState(selected); | ||
| onConnected(); | ||
| } catch (cause) { | ||
| if (connectionErrorCode(cause) === "invalid_certificate") { | ||
| setAdvancedOpen(true); | ||
| } | ||
| setError(cause); | ||
| if (!preview) await refreshConnectionState(onState); | ||
| } finally { | ||
|
|
@@ -911,7 +930,7 @@ export function QuickConnectDialog({ | |
| <DialogCloseButton label={zh ? "关闭弹窗" : "Close dialog"} /> | ||
| </DialogHeader> | ||
| <DialogBody> | ||
| {error != null && ( | ||
| {error != null && !certificateError && ( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P3] Keep invalid CA feedback visible in the dialog viewport on rejection (non-blocking) When an invalid PEM is submitted after collapsing Advanced settings (or after scrolling back to the top of the dialog) at the default 1280×800 window size, Required outcome: scroll the CA field/error into view and focus the CA input when |
||
| <PageFeedback | ||
| compact | ||
| kind="error" | ||
|
|
@@ -1112,6 +1131,59 @@ export function QuickConnectDialog({ | |
| </Select> | ||
| </Field> | ||
| )} | ||
| {supportsCustomCa && ( | ||
| <div className="grid gap-2"> | ||
| <Button | ||
| variant="text" | ||
| size="sm" | ||
| type="button" | ||
| className="justify-self-start" | ||
| aria-controls="quick-connection-advanced" | ||
| aria-expanded={advancedOpen} | ||
| onClick={() => setAdvancedOpen((open) => !open)} | ||
| > | ||
| {zh ? "高级设置" : "Advanced settings"} | ||
| <ChevronDown | ||
| aria-hidden="true" | ||
| className={advancedOpen ? "rotate-180" : undefined} | ||
| /> | ||
| </Button> | ||
| <div id="quick-connection-advanced" hidden={!advancedOpen}> | ||
| <Field> | ||
| <FieldLabel htmlFor="quick-connection-ca-pem"> | ||
| {zh | ||
| ? "CA 证书(PEM,可选)" | ||
| : "CA certificate (PEM, optional)"} | ||
| </FieldLabel> | ||
| <Textarea | ||
| id="quick-connection-ca-pem" | ||
| value={caPem} | ||
| spellCheck={false} | ||
| aria-invalid={certificateError || undefined} | ||
| aria-describedby={ | ||
| certificateError | ||
| ? "quick-connection-ca-help quick-connection-ca-error" | ||
| : "quick-connection-ca-help" | ||
| } | ||
| onChange={(event) => { | ||
| setCaPem(event.target.value); | ||
| setError(null); | ||
| }} | ||
| /> | ||
| <FieldDescription id="quick-connection-ca-help"> | ||
| {zh | ||
| ? "粘贴管理员提供的 CA 证书。Desktop 仅在此连接中额外信任该证书。" | ||
| : "Paste the CA certificate from your administrator. Desktop trusts it alongside system certificates for this connection."} | ||
| </FieldDescription> | ||
| {certificateError && ( | ||
| <FieldError id="quick-connection-ca-error" role="alert"> | ||
| {t.invalid_certificate} | ||
| </FieldError> | ||
| )} | ||
| </Field> | ||
| </div> | ||
| </div> | ||
| )} | ||
| </fieldset> | ||
| </DialogBody> | ||
| <DialogFooter> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] Surface TLS failures from
discoveryandconnectionIdentityas well (non-blocking)In native
session.rs,compatibilityVerifiedis determined bydiscoveryandconnection_identity, whereaslivenessis an independent HTTP request that does not gatecompatibilityVerified. Ifdiscoveryorconnection_identityfails withcode: "tls"whilelivenesssucceeds (e.g. mixed edge TLS config or cert rotation), this branch discards the TLS error and asks the user to select a verified compatibility profile instead.Required outcome: inspect
[active.report.discovery?.error, active.report.connectionIdentity?.error, active.report.liveness.error]for atlserror before falling back tocompatibility_unverified.