fix: the root CA is created by the server, an offline CA or a Simple CA service, chosen at setup; the shell can stay open in a tab of its own, the Docker page is offered only with Docker, and the test scripts are in bin/.
Release / release (push) Failing after 14m20s
Release / release (push) Failing after 14m20s
This commit is contained in:
1 parent
ff0c93ed73
commit
a649331aa2
49 files changed
+1597
-637
No files matched your search
@@ -5,8 +5,8 @@ import Download from '@mui/icons-material/Download'
|
||||
import Edit from '@mui/icons-material/Edit'
|
||||
import Refresh from '@mui/icons-material/Refresh'
|
||||
import Settings from '@mui/icons-material/Settings'
|
||||
import Key from '@mui/icons-material/Key'
|
||||
import UploadFile from '@mui/icons-material/UploadFile'
|
||||
import WarningAmber from '@mui/icons-material/WarningAmber'
|
||||
import {
|
||||
Alert, Box, Button, Chip, IconButton, MenuItem, Stack, Tab, Table, TableBody, TableCell, TableHead, TableRow, Tabs, TextField,
|
||||
Tooltip, Typography,
|
||||
@@ -20,10 +20,12 @@ import IssuingCaDialog from './IssuingCaDialog.tsx'
|
||||
import TemplateDialog from './TemplateDialog.tsx'
|
||||
import Toolbar from './Toolbar.tsx'
|
||||
import EkuDialog from './EkuDialog.tsx'
|
||||
import PkiSettingsDialog, { PUBLISH_LABELS } from './PkiSettingsDialog.tsx'
|
||||
import PkiSettingsDialog, { PUBLISH_LABELS, ROOT_SOURCE_LABELS } from './PkiSettingsDialog.tsx'
|
||||
import { Pairs, Section } from './ServerPanel.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,
|
||||
TOKEN_SHAPE,
|
||||
BUILTIN_TEMPLATES, REVOKE_REASONS, request, type Pki, type PkiCertificate, type PkiIssuingCa, type PkiTemplate,
|
||||
} from './api.ts'
|
||||
import { saveFile } from './saveFile.ts'
|
||||
@@ -32,8 +34,11 @@ import { saveFile } from './saveFile.ts'
|
||||
* built-in issuing CAs, the general-purpose ones. */
|
||||
type View = 'root' | 'templates' | 'usages' | 'p2s' | 's2s' | 'issuing'
|
||||
|
||||
/** The built-in CAs, whose certificates the Issuing CAs tab leaves out. */
|
||||
const BUILTIN_CAS = ['root', 'p2s', 's2s']
|
||||
/** 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']
|
||||
|
||||
/** 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' }
|
||||
|
||||
/** The note shown after a change, which the server applies when linux-manager-setup has run again. */
|
||||
const APPLIED = 'The server applies the change in the background.'
|
||||
@@ -67,8 +72,8 @@ const REASON_LABELS: Record<string, string> = {
|
||||
* 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
|
||||
* 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, and the root takes a CRL signed offline. The root key is managed on the server
|
||||
* with linux-manager-ca only.
|
||||
* 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.
|
||||
*/
|
||||
export default function CertificatesPanel() {
|
||||
const [pki, setPki] = useState<Pki | null>(null)
|
||||
@@ -83,6 +88,7 @@ export default function CertificatesPanel() {
|
||||
const [issuing, setIssuing] = useState(false)
|
||||
const [importing, setImporting] = useState<string | null>(null)
|
||||
const [uploading, setUploading] = useState(false)
|
||||
const [entering, setEntering] = useState(false)
|
||||
const [confirm, setConfirm] = useState<ConfirmDialogProps | null>(null)
|
||||
const [filter, setFilter] = useState('')
|
||||
const [view, setView] = useState<View>('root')
|
||||
@@ -195,7 +201,11 @@ export default function CertificatesPanel() {
|
||||
function removeAuthority(name: string) {
|
||||
setConfirm({
|
||||
title: 'Remove issuing CA',
|
||||
message: `Remove issuing CA ${name}? The server retires it and revokes its certificate on the root CRL; with the root offline, the root CRL is signed offline. Its certificates stay valid until they expire or are revoked.`,
|
||||
message: `Remove issuing CA ${name}? The server retires it. ${{
|
||||
local: 'It revokes its certificate on the root CRL.',
|
||||
offline: 'Its certificate is revoked on the root CRL signed offline.',
|
||||
'simple-ca': 'Its certificate is revoked in Simple CA.',
|
||||
}[pki?.settings.root ?? 'local']} Its certificates stay valid until they expire or are revoked.`,
|
||||
confirmLabel: 'Remove',
|
||||
destructive: true,
|
||||
onCancel: () => setConfirm(null),
|
||||
@@ -314,7 +324,7 @@ export default function CertificatesPanel() {
|
||||
</TableCell>
|
||||
<TableCell align="right" sx={{ whiteSpace: 'nowrap' }}>
|
||||
{authorityOf(certificate) && (
|
||||
<Tooltip title="Download the CA bundle: the issuing CA and the root">
|
||||
<Tooltip title="Download the CA bundle: the issuing CA and the CAs above it">
|
||||
<span>
|
||||
<IconButton size="small" disabled={busy} onClick={() => void downloadBundle(authorityOf(certificate)!.name)}>
|
||||
<Download fontSize="small" />
|
||||
@@ -356,8 +366,10 @@ export default function CertificatesPanel() {
|
||||
/>
|
||||
{authority.state === 'pending' && (
|
||||
<Stack direction="row" sx={{ mt: 1, alignItems: 'center', justifyContent: 'flex-end', gap: 1 }}>
|
||||
<Typography variant="body2" color="text.secondary">Waits for its certificate signed by the root:</Typography>
|
||||
{pendingActions(name)}
|
||||
<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>
|
||||
)}
|
||||
{authority.state === 'active' && (
|
||||
@@ -407,34 +419,51 @@ export default function CertificatesPanel() {
|
||||
{pki && view === 'root' && (
|
||||
<Box sx={{ display: 'grid', gap: 2, gridTemplateColumns: { xs: '1fr', md: '1fr 1fr' } }}>
|
||||
<Section title="Root CA">
|
||||
{root ? (
|
||||
{root && (
|
||||
<>
|
||||
<Pairs
|
||||
rows={[
|
||||
['Subject', root.subject],
|
||||
['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)],
|
||||
['Key', root.key ? (
|
||||
<Box component="span" sx={{ display: 'inline-flex', alignItems: 'center', gap: 0.5 }}>
|
||||
on the server
|
||||
<Tooltip title="Keeping the root key off the server is recommended: linux-manager-ca root export-key, then linux-manager-ca root remove-key.">
|
||||
<WarningAmber fontSize="small" color="warning" aria-label="The root key is on the server" />
|
||||
</Tooltip>
|
||||
</Box>
|
||||
) : 'offline'],
|
||||
['CRL valid until', when(root.crl_next_update)],
|
||||
['CRL', root.crl_source === 'uploaded' ? 'uploaded' : root.crl_source === 'signed' ? 'signed by the server' : '-'],
|
||||
['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 }}>
|
||||
<Button size="small" variant="outlined" startIcon={<Download />} disabled={busy} onClick={() => void downloadBundle('root')}>
|
||||
Download root CA
|
||||
</Button>
|
||||
<Button size="small" variant="outlined" startIcon={<UploadFile />} disabled={busy} onClick={() => setUploading(true)}>
|
||||
Upload CRL
|
||||
</Button>
|
||||
{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>
|
||||
</>
|
||||
) : <Typography variant="body2" color="text.secondary">None yet; the server creates it once a platform is chosen.</Typography>}
|
||||
)}
|
||||
</Section>
|
||||
<Section title="General">
|
||||
<Pairs
|
||||
@@ -447,7 +476,7 @@ export default function CertificatesPanel() {
|
||||
/>
|
||||
</Section>
|
||||
<Section title="Issuing CA certificates" wide>
|
||||
{certificateTable(pki.certificates.filter((certificate) => certificate.ca === 'root'))}
|
||||
{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(', ')}`}
|
||||
@@ -622,9 +651,9 @@ export default function CertificatesPanel() {
|
||||
<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' && pendingActions(authority.name)}
|
||||
{authority.state === 'pending' && pki.settings.root === 'offline' && pendingActions(authority.name)}
|
||||
{authority.state === 'active' && (
|
||||
<Tooltip title="Download the CA bundle: the issuing CA and the root">
|
||||
<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>
|
||||
@@ -721,13 +750,15 @@ export default function CertificatesPanel() {
|
||||
)}
|
||||
{importing && (
|
||||
<ImportDialog
|
||||
title={`Import the certificate of ${importing}`}
|
||||
message="The certificate of the issuing CA, signed by the root CA for the key of its CSR."
|
||||
title={importing === 'root' ? 'Import the root certificate' : `Import the certificate of ${importing}`}
|
||||
message={importing === 'root'
|
||||
? 'The self-signed certificate of the offline root CA; the certificates of the issuing CAs are imported after it.'
|
||||
: 'The certificate of the issuing CA, signed by the root CA for the key of its CSR.'}
|
||||
label="Certificate"
|
||||
begin="-----BEGIN CERTIFICATE-----"
|
||||
onCancel={() => setImporting(null)}
|
||||
onSave={async (certificate) => {
|
||||
await request('PUT', `/ca/issuing/${importing}/certificate`, CA_IMPORTED_SHAPE, { certificate })
|
||||
await request('PUT', importing === 'root' ? '/ca/root/certificate' : `/ca/issuing/${importing}/certificate`, CA_IMPORTED_SHAPE, { certificate })
|
||||
setImporting(null)
|
||||
setNote(APPLIED)
|
||||
await refresh()
|
||||
@@ -748,6 +779,18 @@ export default function CertificatesPanel() {
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{entering && root && (
|
||||
<SetupCodeDialog
|
||||
url={root.simple_ca_url ?? ''}
|
||||
onCancel={() => setEntering(false)}
|
||||
onSave={async (code) => {
|
||||
await request('PUT', '/ca/root/setup-code', TOKEN_SHAPE, { code })
|
||||
setEntering(false)
|
||||
setNote(APPLIED)
|
||||
await refresh()
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{confirm && <ConfirmDialog {...confirm} />}
|
||||
</Box>
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user