import { AlertCircle, Plus, Server, ServerCog, ShieldAlert, User } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent } from "@/components/ui/card"; import { OrgCA } from "@/lib/api"; import { CADetailCard } from "./CADetailCard"; import { IssueHostCertPanel } from "./IssueHostCertPanel"; interface CASectionProps { caType: "user" | "host"; ca: OrgCA | null; onCreateClick: (caType: "user" | "host") => void; onEdit: (ca: OrgCA) => void; onRotate: (ca: OrgCA) => void; onDelete: (ca: OrgCA) => void; } const SECTION_META = { user: { title: "User CA", subtitle: "Signs SSH user certificates. Servers trust users who present a valid cert by adding this CA's public key to TrustedUserCAKeys.", emptyDescription: "No User CA configured. Generate a key pair to start issuing SSH user certificates.", }, host: { title: "Host CA", subtitle: "Signs SSH host certificates. Clients trust servers whose cert is signed by this CA. The CA public key goes in the client's known_hosts — not HostCertificate (that is issued per-server separately).", emptyDescription: "No Host CA configured. Generate a key pair to start issuing SSH host certificates.", }, } as const; // ── Tiny numbered step label used in the Host CA flow ──────────────────────── function StepLabel({ n, label }: { n: number; label: string }) { return (
{n} {label}
); } export function CASection({ caType, ca, onCreateClick, onEdit, onRotate, onDelete, }: CASectionProps) { const isUser = caType === "user"; const { title, subtitle, emptyDescription } = SECTION_META[caType]; const Icon = isUser ? User : Server; const isSystem = !!ca?.is_system; return (
{/* Section header */}

{title}

{/* Only show the verbose subtitle when there's no CA yet */} {!ca && (

{subtitle}

)}
{ca ? ( isSystem ? ( System (read-only) ) : ( Configured ) ) : ( Not configured )}
{/* Content */} {ca ? (
{isUser ? ( /* ── User CA: single card, no numbered steps needed ─────────── */ ) : ( /* ── Host CA: two explicit numbered steps ────────────────────── */ <> {/* Step 1 — CA key → clients' known_hosts */}
{/* Step 2 — sign each server's host public key */} {!isSystem && (
)} )} {/* System CA upgrade prompt */} {isSystem && (

Using server-configured CA

Certificates are being signed by a CA key loaded from the server configuration, not managed through this UI. Generate a managed key below to take full control of certificate issuance from Gatehouse.

)}
) : ( /* Empty state */

No {title} configured

{emptyDescription}

)}
); }