diff --git a/src/lib/shared/repo-predicates.ts b/src/lib/shared/repo-predicates.ts index aef2f53..728d0ff 100644 --- a/src/lib/shared/repo-predicates.ts +++ b/src/lib/shared/repo-predicates.ts @@ -13,6 +13,22 @@ export function isLocalRepo(repository: string): boolean { return repository.startsWith('/') || repository.startsWith('./'); } +/** + * Whether a backup destination's TLS-certificate fields (CA / client cert) are + * meaningful for a given backend type. Only backends that can be self-hosted over + * HTTPS with a private/self-signed CA qualify: `s3` (MinIO/Ceph) and `rest`. A + * local path has no network, and `b2`/`azure`/`gs` are managed clouds served from + * public CAs, so the TLS fields are noise there. When editing a destination that + * already has a cert stored, return true regardless so its data is never hidden. + */ +export function backendSupportsTls( + backendType: string, + opts?: { isEditing?: boolean; hasStoredCert?: boolean } +): boolean { + if (backendType === 's3' || backendType === 'rest') return true; + return !!(opts?.isEditing && opts?.hasStoredCert); +} + /** An environment reachable over the network (hawser or direct-with-host). */ export function isRemoteEnvironment(env?: { connectionType?: string | null; host?: string | null } | null): boolean { if (!env) return false; diff --git a/src/routes/settings/backups/DestinationModal.svelte b/src/routes/settings/backups/DestinationModal.svelte index 5c04525..7d77ff2 100644 --- a/src/routes/settings/backups/DestinationModal.svelte +++ b/src/routes/settings/backups/DestinationModal.svelte @@ -18,6 +18,7 @@ import { FieldLabel } from '$lib/components/ui/field-label'; import { toast } from 'svelte-sonner'; import { focusFirstInput } from '$lib/utils'; + import { backendSupportsTls } from '$lib/shared/repo-predicates'; interface Destination { id: number; @@ -265,6 +266,12 @@ const repoFields = $derived(selectedBackend.fields.filter(f => !f.envKey)); const credentialFields = $derived(selectedBackend.fields.filter(f => f.envKey)); + // TLS certs only apply to backends self-hostable over HTTPS with a private CA + // (S3/REST); hidden for local/B2/Azure/Google Cloud. See backendSupportsTls. + const showTlsSection = $derived( + backendSupportsTls(formBackendType, { isEditing, hasStoredCert: hadCacert || hadTlsClientCert }) + ); + // A field is mandatory unless it opts out (optional) or is a toggle (skipHostKey). function fieldRequired(f: FormField): boolean { return !f.optional && f.key !== 'skipHostKey'; @@ -727,10 +734,11 @@ - + + {#if showTlsSection}
@@ -783,6 +791,7 @@