feature: the VPN, the router, the name server and WebDAV are components switched on the System tab and installed on demand, Caddy from the Ubuntu archive is a dependency and serves every HTTP and HTTPS port, HTTPS is chosen at install, its certificate is of the Servers Issuing CA or self-signed by default, of ACME or of another CA, the issuing CAs are in one tab, a locked account is unlocked again, the name of a CA is fixed once the CA exists, and a run of setup is no longer cut short by a change.
Release / release (push) Failing after 8s

This commit is contained in:
slawek committed 2026-11-24 05:51:27 +01:00
1 parent a649331aa2
commit a7bfabcb89
97 files changed
+4498 -1834

No files matched your search

+221 -210
View File
@@ -21,7 +21,9 @@ import TemplateDialog from './TemplateDialog.tsx'
import Toolbar from './Toolbar.tsx'
import EkuDialog from './EkuDialog.tsx'
import PkiSettingsDialog, { PUBLISH_LABELS, ROOT_SOURCE_LABELS } from './PkiSettingsDialog.tsx'
import { Board, BoardButtons, useBoard, type BoardPanel } from './PanelBoard.tsx'
import { Pairs, Section } from './ServerPanel.tsx'
import ServerCertificatePanel from './ServerCertificatePanel.tsx'
import SetupCodeDialog from './SetupCodeDialog.tsx'
import {
ApiError, BUNDLE_SHAPE, CA_IMPORTED_SHAPE, CRL_IMPORTED_SHAPE, CSR_SHAPE, ISSUED_SHAPE, PFX_SHAPE, PKI_SETTINGS_SHAPE, PKI_SHAPE, REVOKED_SHAPE,
@@ -30,12 +32,16 @@ import {
} from './api.ts'
import { saveFile } from './saveFile.ts'
/** The tabs of the page: the root and the general information, the templates, the extended key usages, the two
* built-in issuing CAs, the general-purpose ones. */
type View = 'root' | 'templates' | 'usages' | 'p2s' | 's2s' | 'issuing'
/** The tabs of the page: the server's HTTPS (ServerCertificatePanel), the root and the general information, the
* templates, the extended key usages, the issuing CAs. */
type View = 'server' | 'root' | 'templates' | 'usages' | 'issuing'
/** The built-in CAs and the Simple CA issuing CA above them, whose certificates the Issuing CAs tab leaves out. */
const BUILTIN_CAS = ['root', 'upstream', 'p2s', 's2s']
/** The localStorage keys of the layouts of the Root and the Issuing CAs tabs. */
const ROOT_LAYOUT_KEY = 'linux-manager-ui.certificates-root-layout'
const ISSUING_LAYOUT_KEY = 'linux-manager-ui.certificates-issuing-layout'
/** The CAs above the issuing CAs, whose certificates the Issuing CAs tab leaves out. */
const UPPER_CAS = ['root', 'upstream']
/** Where the root CRL came from. */
const CRL_SOURCE_LABELS: Record<string, string> = { signed: 'signed by the server', uploaded: 'uploaded', fetched: 'fetched from Simple CA' }
@@ -48,6 +54,7 @@ const STATE_COLORS: Record<string, 'success' | 'warning' | 'error' | 'default'>
active: 'success',
valid: 'success',
pending: 'warning',
off: 'default',
missing: 'error',
expired: 'default',
revoked: 'error',
@@ -65,15 +72,17 @@ const REASON_LABELS: Record<string, string> = {
/**
* The server's PKI in tabs: Root, the root CA with the general settings and the certificates of the issuing CAs;
* The server's certificates in tabs: Server, the server's HTTPS (ServerCertificatePanel), shown first and also
* while the PKI cannot be read; Root, the root CA with the general settings and the certificates of the issuing CAs;
* Templates, the certificate templates, which are added, changed, removed and reset there; Extended key usages, the
* built-in ones and the custom ones, which are added, changed and removed there; P2S Issuing CA and S2S
* Issuing CA, each built-in CA with the certificates it issued; Issuing CAs, the general-purpose CAs, which are added,
* changed and removed there, with their certificates, filtered by CA. The warnings, Issue and Settings
* are above the tabs. Settings edits the pki section, Issue issues a certificate from a CSR or into a PFX file, a
* built-in ones and the custom ones, which are added, changed and removed there; Issuing CAs, the built-in p2s, s2s and
* servers and the custom CAs, which are added, changed and removed there, with the certificates of all of them, filtered
* by CA. The warnings are above the tabs, and so are Issue and Settings but on the Server tab, whose Refresh reads it
* again. Settings edits the pki section, Issue issues a certificate from a CSR or into a PFX file, a
* certificate of another system or of the server is revoked, an issuing CA waiting for the offline root gives its CSR
* and takes its signed certificate, the offline root takes its certificate and a CRL signed offline, and a Simple CA
* root takes a setup code for a new token.
* root takes a setup code for a new token. The panels of the Root and the Issuing CAs tabs are on a PanelBoard per tab
* whose layout is kept in the browser.
*/
export default function CertificatesPanel() {
const [pki, setPki] = useState<Pki | null>(null)
@@ -91,7 +100,10 @@ export default function CertificatesPanel() {
const [entering, setEntering] = useState(false)
const [confirm, setConfirm] = useState<ConfirmDialogProps | null>(null)
const [filter, setFilter] = useState('')
const [view, setView] = useState<View>('root')
const [view, setView] = useState<View>('server')
const [serverRead, setServerRead] = useState(0)
const rootBoard = useBoard(ROOT_LAYOUT_KEY)
const issuingBoard = useBoard(ISSUING_LAYOUT_KEY)
const refresh = useCallback(async () => {
setBusy(true)
@@ -257,11 +269,11 @@ export default function CertificatesPanel() {
}
const root = pki?.status.root
const general = pki?.status.authorities.filter((authority) => !authority.builtin) ?? []
const generalNames = [...new Set([...general.map((authority) => authority.name),
...(pki?.certificates ?? []).map((certificate) => certificate.ca).filter((name) => !BUILTIN_CAS.includes(name))])]
const generalCertificates = (pki?.certificates ?? [])
.filter((certificate) => !BUILTIN_CAS.includes(certificate.ca) && (filter === '' || certificate.ca === filter))
const authorities = pki?.status.authorities ?? []
const authorityNames = [...new Set([...authorities.map((authority) => authority.name),
...(pki?.certificates ?? []).map((certificate) => certificate.ca).filter((name) => !UPPER_CAS.includes(name))])]
const issuedCertificates = (pki?.certificates ?? [])
.filter((certificate) => !UPPER_CAS.includes(certificate.ca) && (filter === '' || certificate.ca === filter))
/** The actions of an issuing CA waiting for the offline root: download its CSR and import its signed certificate. */
const pendingActions = (name: string) => (
@@ -347,56 +359,198 @@ export default function CertificatesPanel() {
</Box>
)
/** A tab of a built-in issuing CA: its details, the actions while it waits for the offline root, its certificates. */
const builtinTab = (name: 'p2s' | 's2s', title: string) => {
const authority = pki?.status.authorities.find((item) => item.name === name)
return (
<Box sx={{ display: 'grid', gap: 2 }}>
<Section title={title}>
{authority ? (
const rootPanels: BoardPanel[] = pki ? [
{
id: 'root',
title: 'Root CA',
content: (
<>
{root && (
<>
<Pairs
rows={[
['Common name', authority.subject ?? authority.common_name],
['State', <Chip size="small" label={authority.state} color={STATE_COLORS[authority.state] ?? 'default'} />],
['Expires', when(authority.expires)],
['CRL valid until', when(authority.crl_next_update)],
['Templates', authority.templates.join(', ')],
['Source', root.source === 'simple-ca' ? `Simple CA, ${root.simple_ca_url}` : ROOT_SOURCE_LABELS[root.source]],
['State', <Chip size="small" label={root.state} color={STATE_COLORS[root.state] ?? 'default'} />],
['Subject', root.subject ?? '-'],
['Expires', when(root.expires)],
['CRL valid until', when(root.crl_next_update)],
['CRL', CRL_SOURCE_LABELS[root.crl_source ?? ''] ?? '-'],
...(root.upstream ? [
['Simple CA issuing CA', `${root.upstream.name}: ${root.upstream.subject}`],
['Its expiry', when(root.upstream.expires)],
['Its CRL valid until', when(root.upstream.crl_next_update)],
] as [string, string][] : []),
...(root.source === 'simple-ca' ? [['Token valid until', root.token_expires ? when(root.token_expires) : 'no token']] as [string, string][] : []),
]}
/>
{authority.state === 'pending' && (
<Stack direction="row" sx={{ mt: 1, alignItems: 'center', justifyContent: 'flex-end', gap: 1 }}>
<Typography variant="body2" color="text.secondary">
{pki?.settings.root === 'offline' ? 'Waits for its certificate signed by the root:' : 'Waits for its certificate signed by Simple CA.'}
</Typography>
{pki?.settings.root === 'offline' && pendingActions(name)}
</Stack>
{root.state === 'pending' && root.source === 'local' && (
<Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>The server creates it once a platform is chosen.</Typography>
)}
{authority.state === 'active' && (
<Stack direction="row" sx={{ mt: 1, justifyContent: 'flex-end' }}>
<Button size="small" variant="outlined" startIcon={<Download />} disabled={busy} onClick={() => void downloadBundle(name)}>
Download CA bundle
<Stack direction="row" sx={{ mt: 1, justifyContent: 'flex-end', gap: 1 }}>
{root.state === 'active' && (
<Button size="small" variant="outlined" startIcon={<Download />} disabled={busy} onClick={() => void downloadBundle('root')}>
Download root CA
</Button>
</Stack>
)}
)}
{root.source === 'offline' && root.state === 'pending' && (
<Button size="small" variant="outlined" startIcon={<UploadFile />} disabled={busy} onClick={() => setImporting('root')}>
Import root certificate
</Button>
)}
{root.source === 'offline' && root.state === 'active' && (
<Button size="small" variant="outlined" startIcon={<UploadFile />} disabled={busy} onClick={() => setUploading(true)}>
Upload CRL
</Button>
)}
{root.source === 'simple-ca' && (
<Button size="small" variant="outlined" startIcon={<Key />} disabled={busy} onClick={() => setEntering(true)}>
Enter setup code
</Button>
)}
</Stack>
</>
) : <Typography variant="body2" color="text.secondary">None yet; the server creates it once a platform is chosen.</Typography>}
</Section>
<Section title="Certificates issued">{certificateTable((pki?.certificates ?? []).filter((certificate) => certificate.ca === name))}</Section>
</Box>
)
}
)}
</>
),
},
{
id: 'general',
title: 'General',
content: (
<Pairs
rows={[
['Published at', pki.settings.publish.map((item) => PUBLISH_LABELS[item] ?? item).join('; ') || 'nowhere'],
['CA key', pki.settings.key],
['Lifetimes', `root ${pki.settings.root_days} days, issuing CAs ${pki.settings.ca_days} days`],
['CRLs', `issuing CAs ${pki.settings.crl_days} days, root ${pki.settings.root_crl_days} days`],
]}
/>
),
},
{
id: 'certificates',
title: 'Issuing CA certificates',
wide: true,
content: (
<>
{certificateTable(pki.certificates.filter((certificate) => certificate.ca === 'root' || certificate.ca === 'upstream'))}
{pki.status.retired.length > 0 && (
<Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
{`Retired: ${pki.status.retired.map((retired) => `${retired.name} (${when(retired.retired)})`).join(', ')}`}
</Typography>
)}
</>
),
},
] : []
const issuingPanels: BoardPanel[] = pki ? [
{
id: 'authorities',
title: 'Issuing CAs',
wide: true,
content: (
<>
<Stack direction="row" sx={{ mb: 1, justifyContent: 'flex-end' }}>
<Button size="small" variant="outlined" startIcon={<Add />} disabled={busy} onClick={() => setAuthority({})}>
Add issuing CA
</Button>
</Stack>
<Box sx={{ overflowX: 'auto' }}>
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Name</TableCell>
<TableCell>Common name</TableCell>
<TableCell>State</TableCell>
<TableCell>Expires</TableCell>
<TableCell>CRL valid until</TableCell>
<TableCell>Templates</TableCell>
<TableCell>ACME</TableCell>
<TableCell align="right">Actions</TableCell>
</TableRow>
</TableHead>
<TableBody>
{authorities.map((authority) => (
<TableRow key={authority.name} hover>
<TableCell sx={{ whiteSpace: 'nowrap' }}>
{authority.name}
{authority.builtin && <Chip size="small" label="built-in" variant="outlined" sx={{ ml: 1 }} />}
</TableCell>
<TableCell>{authority.subject ?? authority.common_name}</TableCell>
<TableCell>
<Tooltip title={authority.state === 'off' ? `Made once ${authority.component}.enabled is true` : ''}>
<Chip size="small" label={authority.state} color={STATE_COLORS[authority.state] ?? 'default'} />
</Tooltip>
</TableCell>
<TableCell>{when(authority.expires)}</TableCell>
<TableCell>{when(authority.crl_next_update)}</TableCell>
<TableCell>{authority.templates.join(', ')}</TableCell>
<TableCell sx={{ wordBreak: 'break-all' }}>{authority.acme_url ?? (authority.acme ? 'waits for the certificate' : '-')}</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>
{authority.state === 'pending' && pki.settings.root === 'offline' && pendingActions(authority.name)}
{authority.state === 'active' && (
<Tooltip title="Download the CA bundle: the issuing CA and the CAs above it">
<span>
<IconButton size="small" disabled={busy} onClick={() => void downloadBundle(authority.name)}><Download fontSize="small" /></IconButton>
</span>
</Tooltip>
)}
{!authority.builtin && (
<>
<Tooltip title="Edit">
<span>
<IconButton size="small" disabled={busy} onClick={() => setAuthority({ name: authority.name })}><Edit fontSize="small" /></IconButton>
</span>
</Tooltip>
<Tooltip title="Remove">
<span>
<IconButton size="small" color="error" disabled={busy} onClick={() => removeAuthority(authority.name)}><Delete fontSize="small" /></IconButton>
</span>
</Tooltip>
</>
)}
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Box>
</>
),
},
{
id: 'certificates',
title: 'Certificates issued',
wide: true,
content: (
<>
<TextField select size="small" label="Issuing CA" value={filter} sx={{ mb: 1, minWidth: 200 }} onChange={(event) => setFilter(event.target.value)}>
<MenuItem value="">All</MenuItem>
{authorityNames.map((name) => <MenuItem key={name} value={name}>{name}</MenuItem>)}
</TextField>
{certificateTable(issuedCertificates)}
</>
),
},
] : []
return (
<Box component="section">
<Toolbar description="The root CA and the issuing CAs for P2S, site-to-site and general use.">
<Button variant="contained" startIcon={<Add />} disabled={busy || pki === null} onClick={() => setIssuing(true)}>
Issue
</Button>
<Button variant="outlined" startIcon={<Settings />} disabled={busy || pki === null} onClick={() => setEditing(true)}>
Settings
</Button>
<Button variant="outlined" startIcon={<Refresh />} disabled={busy} onClick={() => void refresh()}>
<Toolbar description="The server's HTTPS certificate and ACME CA, the root CA and the issuing CAs for P2S, site-to-site, servers and custom uses.">
{view !== 'server' && (
<>
<Button variant="contained" startIcon={<Add />} disabled={busy || pki === null} onClick={() => setIssuing(true)}>
Issue
</Button>
<Button variant="outlined" startIcon={<Settings />} disabled={busy || pki === null} onClick={() => setEditing(true)}>
Settings
</Button>
</>
)}
{view === 'root' && <BoardButtons board={rootBoard} />}
{view === 'issuing' && <BoardButtons board={issuingBoard} />}
<Button variant="outlined" startIcon={<Refresh />} disabled={busy} onClick={() => view === 'server' ? setServerRead(serverRead + 1) : void refresh()}>
Refresh
</Button>
</Toolbar>
@@ -405,86 +559,17 @@ export default function CertificatesPanel() {
{note && <Alert severity="info" sx={{ mb: 2 }} onClose={() => setNote(null)}>{note}</Alert>}
{pki?.status.warnings.map((warning) => <Alert key={warning} severity="warning" sx={{ mb: 2 }}>{warning}</Alert>)}
{pki && (
<Tabs value={view} onChange={(_event, next: View) => setView(next)} sx={{ mb: 2, borderBottom: 1, borderColor: 'divider' }}>
<Tab value="root" label="Root" />
<Tab value="templates" label="Templates" />
<Tab value="usages" label="Extended key usages" />
<Tab value="p2s" label="P2S Issuing CA" />
<Tab value="s2s" label="S2S Issuing CA" />
<Tab value="issuing" label="Issuing CAs" />
</Tabs>
)}
<Tabs value={view} onChange={(_event, next: View) => setView(next)} sx={{ mb: 2, borderBottom: 1, borderColor: 'divider' }}>
<Tab value="server" label="Server" />
{pki && <Tab value="root" label="Root" />}
{pki && <Tab value="templates" label="Templates" />}
{pki && <Tab value="usages" label="Extended key usages" />}
{pki && <Tab value="issuing" label="Issuing CAs" />}
</Tabs>
{pki && view === 'root' && (
<Box sx={{ display: 'grid', gap: 2, gridTemplateColumns: { xs: '1fr', md: '1fr 1fr' } }}>
<Section title="Root CA">
{root && (
<>
<Pairs
rows={[
['Source', root.source === 'simple-ca' ? `Simple CA, ${root.simple_ca_url}` : ROOT_SOURCE_LABELS[root.source]],
['State', <Chip size="small" label={root.state} color={STATE_COLORS[root.state] ?? 'default'} />],
['Subject', root.subject ?? '-'],
['Expires', when(root.expires)],
['CRL valid until', when(root.crl_next_update)],
['CRL', CRL_SOURCE_LABELS[root.crl_source ?? ''] ?? '-'],
...(root.upstream ? [
['Simple CA issuing CA', `${root.upstream.name}: ${root.upstream.subject}`],
['Its expiry', when(root.upstream.expires)],
['Its CRL valid until', when(root.upstream.crl_next_update)],
] as [string, string][] : []),
...(root.source === 'simple-ca' ? [['Token valid until', root.token_expires ? when(root.token_expires) : 'no token']] as [string, string][] : []),
]}
/>
{root.state === 'pending' && root.source === 'local' && (
<Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>The server creates it once a platform is chosen.</Typography>
)}
<Stack direction="row" sx={{ mt: 1, justifyContent: 'flex-end', gap: 1 }}>
{root.state === 'active' && (
<Button size="small" variant="outlined" startIcon={<Download />} disabled={busy} onClick={() => void downloadBundle('root')}>
Download root CA
</Button>
)}
{root.source === 'offline' && root.state === 'pending' && (
<Button size="small" variant="outlined" startIcon={<UploadFile />} disabled={busy} onClick={() => setImporting('root')}>
Import root certificate
</Button>
)}
{root.source === 'offline' && root.state === 'active' && (
<Button size="small" variant="outlined" startIcon={<UploadFile />} disabled={busy} onClick={() => setUploading(true)}>
Upload CRL
</Button>
)}
{root.source === 'simple-ca' && (
<Button size="small" variant="outlined" startIcon={<Key />} disabled={busy} onClick={() => setEntering(true)}>
Enter setup code
</Button>
)}
</Stack>
</>
)}
</Section>
<Section title="General">
<Pairs
rows={[
['Published at', pki.settings.publish.map((item) => PUBLISH_LABELS[item] ?? item).join('; ') || 'nowhere'],
['CA key', pki.settings.key],
['Lifetimes', `root ${pki.settings.root_days} days, issuing CAs ${pki.settings.ca_days} days`],
['CRLs', `issuing CAs ${pki.settings.crl_days} days, root ${pki.settings.root_crl_days} days`],
]}
/>
</Section>
<Section title="Issuing CA certificates" wide>
{certificateTable(pki.certificates.filter((certificate) => certificate.ca === 'root' || certificate.ca === 'upstream'))}
{pki.status.retired.length > 0 && (
<Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
{`Retired: ${pki.status.retired.map((retired) => `${retired.name} (${when(retired.retired)})`).join(', ')}`}
</Typography>
)}
</Section>
</Box>
)}
{view === 'server' && <ServerCertificatePanel key={serverRead} />}
{pki && view === 'root' && <Board board={rootBoard} panels={rootPanels} />}
{pki && view === 'templates' && (
<Box sx={{ display: 'grid', gap: 2 }}>
@@ -610,81 +695,7 @@ export default function CertificatesPanel() {
</Box>
)}
{pki && view === 'p2s' && builtinTab('p2s', 'P2S Issuing CA: the VPN server certificate and the users\' certificates')}
{pki && view === 's2s' && builtinTab('s2s', 'S2S Issuing CA: the site-to-site certificates of the server and its peers')}
{pki && view === 'issuing' && (
<Box sx={{ display: 'grid', gap: 2 }}>
<Section title="General-purpose issuing CAs">
<Stack direction="row" sx={{ mb: 1, justifyContent: 'flex-end' }}>
<Button size="small" variant="outlined" startIcon={<Add />} disabled={busy} onClick={() => setAuthority({})}>
Add issuing CA
</Button>
</Stack>
<Box sx={{ overflowX: 'auto' }}>
<Table size="small">
<TableHead>
<TableRow>
<TableCell>Name</TableCell>
<TableCell>Common name</TableCell>
<TableCell>State</TableCell>
<TableCell>Expires</TableCell>
<TableCell>CRL valid until</TableCell>
<TableCell>Templates</TableCell>
<TableCell>ACME</TableCell>
<TableCell align="right">Actions</TableCell>
</TableRow>
</TableHead>
<TableBody>
{general.length === 0 && (
<TableRow>
<TableCell colSpan={8} sx={{ color: 'text.secondary' }}>None.</TableCell>
</TableRow>
)}
{general.map((authority) => (
<TableRow key={authority.name} hover>
<TableCell>{authority.name}</TableCell>
<TableCell>{authority.subject ?? authority.common_name}</TableCell>
<TableCell><Chip size="small" label={authority.state} color={STATE_COLORS[authority.state] ?? 'default'} /></TableCell>
<TableCell>{when(authority.expires)}</TableCell>
<TableCell>{when(authority.crl_next_update)}</TableCell>
<TableCell>{authority.templates.join(', ')}</TableCell>
<TableCell sx={{ wordBreak: 'break-all' }}>{authority.acme_url ?? (authority.acme ? 'waits for the certificate' : '-')}</TableCell>
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>
{authority.state === 'pending' && pki.settings.root === 'offline' && pendingActions(authority.name)}
{authority.state === 'active' && (
<Tooltip title="Download the CA bundle: the issuing CA and the CAs above it">
<span>
<IconButton size="small" disabled={busy} onClick={() => void downloadBundle(authority.name)}><Download fontSize="small" /></IconButton>
</span>
</Tooltip>
)}
<Tooltip title="Edit">
<span>
<IconButton size="small" disabled={busy} onClick={() => setAuthority({ name: authority.name })}><Edit fontSize="small" /></IconButton>
</span>
</Tooltip>
<Tooltip title="Remove">
<span>
<IconButton size="small" color="error" disabled={busy} onClick={() => removeAuthority(authority.name)}><Delete fontSize="small" /></IconButton>
</span>
</Tooltip>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</Box>
</Section>
<Section title="Certificates issued">
<TextField select size="small" label="Issuing CA" value={filter} sx={{ mb: 1, minWidth: 200 }} onChange={(event) => setFilter(event.target.value)}>
<MenuItem value="">All</MenuItem>
{generalNames.map((name) => <MenuItem key={name} value={name}>{name}</MenuItem>)}
</TextField>
{certificateTable(generalCertificates)}
</Section>
</Box>
)}
{pki && view === 'issuing' && <Board board={issuingBoard} panels={issuingPanels} />}
{editing && pki && (
<PkiSettingsDialog