feature: the CA certificates and CRLs are always published over HTTP and HTTPS on the status and Manager ports, the Shell page is an entry of the page menu, and the web interface passes its lint.
Release / release (push) Successful in 26s

This commit is contained in:
slawek committed 2026-11-24 18:06:34 +01:00
1 parent 4b5318c676
commit 0cec95c19b
72 files changed
+910 -861

No files matched your search

+5 -80
View File
@@ -1,72 +1,15 @@
import {
Alert, Box, Button, Checkbox, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, MenuItem, Stack, TextField,
Typography,
Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, MenuItem, Stack, TextField, Typography,
} from '@mui/material'
import { useState, type FormEvent } from 'react'
import { PKI_KEYS, PKI_PUBLISH, type Pki, type PkiAuthority, type PkiRootSource, type PkiSettings, type PkiTemplate } from './api.ts'
/** The labels of the publishing endpoints. */
export const PUBLISH_LABELS: Record<string, string> = {
http: 'HTTP on the status port, served by the web service',
'http-80': 'HTTP on port 80, served by Caddy',
https: 'HTTPS on the HTTPS status port, served by Caddy',
'https-default': 'HTTPS on port 443, served by Caddy',
}
/** The labels of the sources of the root CA. */
export const ROOT_SOURCE_LABELS: Record<PkiRootSource, string> = {
local: 'Created by the server',
offline: 'Offline',
'simple-ca': 'Simple CA',
}
/** The name of an issuing CA or a template, as the server accepts it. */
export const NAME_PATTERN = /^[a-z][a-z0-9-]{0,30}$/
/** The names the issuing CAs of pki.issuing_cas cannot have. */
export const RESERVED = ['root', 'upstream', 'p2s', 's2s', 'servers']
/** The longest common name of a CA, in characters. */
const CA_NAME_MAX = 64
/** The longest lifetime the server accepts, in days. */
const DAYS_MAX = 36500
/** A new template's options. */
export const NEW_TEMPLATE: PkiTemplate = {
key: 'rsa-3072', days: 365, key_usage: ['digital_signature'], extended_key_usage: [], subject: 'name', sans: [], policies: [],
}
/** Whether an issuing CA has its certificate or its CSR, which fix its common name. */
export function made(authority: PkiAuthority) {
return authority.state === 'active' || authority.state === 'pending'
}
/** A common name's problem, or ''. */
export function nameProblem(value: string) {
return value.trim() === '' || value.trim().length > CA_NAME_MAX ? `1 to ${CA_NAME_MAX} characters.` : ''
}
/** The problem of the URL of a Simple CA service, or ''. */
export function urlProblem(value: string) {
try {
const url = new URL(value.trim())
return url.protocol === 'https:' && url.hostname !== '' && url.search === '' && url.hash === '' ? '' : 'An https:// URL.'
} catch {
return 'An https:// URL.'
}
}
/** A lifetime's problem, or ''. */
export function daysProblem(value: number) {
return !Number.isInteger(value) || value < 1 || value > DAYS_MAX ? `1 to ${DAYS_MAX} days.` : ''
}
import { PKI_KEYS, type Pki, type PkiSettings } from './api.ts'
import { ROOT_SOURCE_LABELS, daysProblem, made, nameProblem, urlProblem } from './pki.ts'
/**
* A dialog that edits the server's pki section but the general-purpose issuing CAs, the templates and the custom
* extended key usages, which IssuingCaDialog, TemplateDialog and EkuDialog edit: the names of the P2S and site-to-site
* CAs, the lifetimes and key type of the CAs, the validity of the CRLs, where certificates and CRLs are published and,
* with a Simple CA root, the URL of the service. The source of the root is shown and not edited, as it is fixed once
* CAs, the lifetimes and key type of the CAs, the validity of the CRLs and, with a Simple CA root, the URL of the
* service. The source of the root is shown and not edited, as it is fixed once
* the root exists. The root and the Servers CA are made by the first setup, so their names are not shown; the P2S and
* site-to-site CAs are made when the VPN and the router are switched on, and their names are fixed from then on. The
* server applies the lifetimes and key type when it creates a CA. onSave sends the settings; the dialog closes when it
@@ -188,24 +131,6 @@ export default function PkiSettingsDialog(props: {
onChange={(event) => change({ root_crl_days: number(event.target.value) })}
/>
</Stack>
<Typography variant="subtitle2">Published certificates and CRLs</Typography>
<Box>
{PKI_PUBLISH.map((item) => (
<FormControlLabel
key={item}
sx={{ display: 'flex' }}
control={
<Checkbox
checked={settings.publish.includes(item)}
onChange={(event) => change({
publish: PKI_PUBLISH.filter((name) => (name === item ? event.target.checked : settings.publish.includes(name))),
})}
/>
}
label={PUBLISH_LABELS[item]}
/>
))}
</Box>
</Stack>
</DialogContent>
<DialogActions>