import { open } from "@tauri-apps/plugin-dialog"; import { Input } from "../ui/Input"; import { SelectDropdown } from "../ui/SelectDropdown"; import { useNotificationStore } from "../../stores/notificationStore"; export interface SslFieldsProps { values: Record; onChange: (updates: Record) => void; } const SSL_MODE_OPTIONS = [ { value: "disable", label: "Disable" }, { value: "require", label: "Require" }, { value: "verify-ca", label: "Verify CA" }, { value: "verify-full", label: "Verify Full" }, ]; export function SslFields({ values, onChange }: SslFieldsProps) { const notify = useNotificationStore((s) => s.notify); const mode = (values.ssl_mode as string) ?? "disable"; const showCertFields = mode === "verify-ca" || mode === "verify-full"; const handlePickFile = async (field: string) => { try { const path = await open({ multiple: false, directory: false }); if (path) { onChange({ [field]: path }); } } catch { notify("File picker not available", "error"); } }; return (
onChange({ ssl_mode: value })} options={SSL_MODE_OPTIONS} aria-label="SSL Mode" />
{mode === "require" && (

Require mode is vulnerable to man-in-the-middle attacks because it does not verify the server certificate.

)} {showCertFields && ( <>
onChange({ ssl_ca_cert: value })} placeholder="/path/to/ca-cert.pem" aria-label="CA Certificate" />
onChange({ ssl_client_cert: value })} placeholder="/path/to/client-cert.pem" aria-label="Client Certificate" />
onChange({ ssl_client_key: value })} placeholder="/path/to/client-key.pem" aria-label="Client Key" />
)}
); }