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

This commit is contained in:
slawek committed 2026-11-23 06:45:23 +01:00
1 parent ff0c93ed73
commit a649331aa2
49 files changed
+1597 -637

No files matched your search

+37 -7
View File
@@ -3,7 +3,7 @@ import {
Typography,
} from '@mui/material'
import { useState, type FormEvent } from 'react'
import { PKI_KEYS, PKI_PUBLISH, type Pki, type PkiSettings, type PkiTemplate } from './api.ts'
import { PKI_KEYS, PKI_PUBLISH, type Pki, type PkiRootSource, type PkiSettings, type PkiTemplate } from './api.ts'
/** The labels of the publishing endpoints. */
export const PUBLISH_LABELS: Record<string, string> = {
@@ -13,11 +13,18 @@ export const PUBLISH_LABELS: Record<string, string> = {
'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', 'p2s', 's2s']
export const RESERVED = ['root', 'upstream', 'p2s', 's2s']
/** The longest common name of a CA, in characters. */
const CA_NAME_MAX = 64
@@ -35,6 +42,16 @@ 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.` : ''
@@ -43,9 +60,10 @@ export function daysProblem(value: number) {
/**
* 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, lifetimes and key type of
* the CAs, the validity of the CRLs and
* where certificates and CRLs are published. The server applies the names, lifetimes and key type when it creates a
* CA. onSave sends the settings; the dialog closes when it succeeds and shows the server's message when it fails.
* 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 the root exists. The server applies
* the names, lifetimes and key type when it creates a CA. onSave sends the settings; the dialog closes when it
* succeeds and shows the server's message when it fails.
*/
export default function PkiSettingsDialog(props: {
pki: Pki
@@ -60,6 +78,7 @@ export default function PkiSettingsDialog(props: {
const blocked = [
nameProblem(settings.root_name), nameProblem(settings.p2s_name), nameProblem(settings.s2s_name),
daysProblem(settings.root_days), daysProblem(settings.ca_days), daysProblem(settings.crl_days), daysProblem(settings.root_crl_days),
settings.root === 'simple-ca' ? urlProblem(settings.simple_ca_url) : '',
].some((problem) => problem !== '')
async function submit(event: FormEvent) {
@@ -90,7 +109,18 @@ export default function PkiSettingsDialog(props: {
Names, lifetimes and the key type apply when the server creates a CA; URLs apply to the certificates signed afterwards.
</Typography>
<Typography variant="subtitle2">CAs</Typography>
{(['root', 'p2s', 's2s'] as const).map((name) => {
<TextField label="Root CA source" value={ROOT_SOURCE_LABELS[settings.root]} disabled helperText="Fixed once the root exists." />
{settings.root === 'simple-ca' && (
<TextField
label="Simple CA URL"
value={settings.simple_ca_url}
autoComplete="off"
error={urlProblem(settings.simple_ca_url) !== ''}
helperText={urlProblem(settings.simple_ca_url) || 'The service the server exchanges setup codes with and has its issuing CAs signed by.'}
onChange={(event) => change({ simple_ca_url: event.target.value.trim() })}
/>
)}
{(['root', 'p2s', 's2s'] as const).filter((name) => name !== 'root' || settings.root === 'local').map((name) => {
const option = `${name}_name` as 'root_name' | 'p2s_name' | 's2s_name'
return (
<TextField
@@ -144,7 +174,7 @@ export default function PkiSettingsDialog(props: {
type="number"
value={settings.root_crl_days}
error={daysProblem(settings.root_crl_days) !== ''}
helperText={daysProblem(settings.root_crl_days) || 'When the server signs it, with the root key on the server.'}
helperText={daysProblem(settings.root_crl_days) || 'When the server signs it, for a root the server created.'}
onChange={(event) => change({ root_crl_days: number(event.target.value) })}
/>
</Stack>