Certificates: an automatic order's names follow its account, not the DNS setting (#261) #262
No files matched your search
@@ -20,7 +20,7 @@ import { useSchemaStore } from '@/stores/schemaStore';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { orderNames } from './names';
|
||||
import { canOrderAgain, orderAgainSet, renewalState, type RenewalState } from './orders';
|
||||
import { coveringCert, fmtDate, type CertRow, type Loaded, load, pollOrders, refusal } from './shared';
|
||||
import { coveringCert, fmtDate, type CertRow, type Loaded, load, orderingMethod, pollOrders, refusal } from './shared';
|
||||
import { ORDER_WIZARD_VIEW } from './CertificateSetupCard';
|
||||
|
||||
interface State {
|
||||
@@ -142,7 +142,7 @@ export function CertificateOrdersPanel({ className }: { className?: string }) {
|
||||
{automatic.length > 0 && (
|
||||
<ul className="divide-y rounded-lg border text-sm">
|
||||
{automatic.map((d) => {
|
||||
const method = d.dnsAutomatic ? 'dns' : 'tls';
|
||||
const method = orderingMethod(d.providerId, d.dnsAutomatic, state.data.providers);
|
||||
const names = orderNames(d.name, method, state.data.serverName, d.zone, d.hostnames);
|
||||
const cert = coveringCert(state.certs, names);
|
||||
const task = state.tasks.find((x) => x.domainId === d.id);
|
||||
|
||||
@@ -55,6 +55,7 @@ import {
|
||||
LE_STAGING,
|
||||
type Loaded,
|
||||
load,
|
||||
orderingMethod,
|
||||
pollOrders,
|
||||
PORT,
|
||||
providerFor,
|
||||
@@ -134,8 +135,13 @@ export function OrderCertificatePage() {
|
||||
const domain: DomainRow | undefined = candidates.find((d) => d.id === domainId) ?? candidates[0];
|
||||
const method: Method = domain?.dnsAutomatic ? 'dns' : 'tls';
|
||||
const wildcardBlocked = method === 'tls' && names.some(isWildcard);
|
||||
// What the domain orders today goes by its own account, not by how this order will be checked.
|
||||
const currentMethod = useMemo(
|
||||
() => orderingMethod(domain?.providerId, !!domain?.dnsAutomatic, data?.providers ?? []),
|
||||
[data, domain],
|
||||
);
|
||||
const currentNames = domain?.automatic
|
||||
? orderNames(domain.name, method, data?.serverName ?? '', domain.zone, domain.hostnames)
|
||||
? orderNames(domain.name, currentMethod, data?.serverName ?? '', domain.zone, domain.hostnames)
|
||||
: [];
|
||||
const unchanged = !!domain?.automatic && sameNames(currentNames, names);
|
||||
const replaced = domain?.automatic && !unchanged ? currentNames.filter((n) => !names.includes(n)) : [];
|
||||
@@ -298,7 +304,9 @@ export function OrderCertificatePage() {
|
||||
</p>
|
||||
);
|
||||
const how =
|
||||
method === 'dns' ? t('certSetup.howDnsWord', 'through DNS') : t('certSetup.howTlsWord', 'on port {{port}}', { port });
|
||||
method === 'dns'
|
||||
? t('certSetup.howDnsWord', 'through DNS')
|
||||
: t('certSetup.howTlsWord', 'on port {{port}}', { port });
|
||||
|
||||
// ── Step 1: names (also where it goes back to if the domain stops fitting) ──
|
||||
if (step === 0 || !domain) {
|
||||
|
||||
@@ -5,7 +5,16 @@
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { challengeOf, defaultDirect, LE_PRODUCTION, LE_STAGING, PORT, providerFor, type ProviderRow } from './shared';
|
||||
import {
|
||||
challengeOf,
|
||||
defaultDirect,
|
||||
LE_PRODUCTION,
|
||||
LE_STAGING,
|
||||
orderingMethod,
|
||||
PORT,
|
||||
providerFor,
|
||||
type ProviderRow,
|
||||
} from './shared';
|
||||
|
||||
const row = (id: string, challengeType: string, directory = LE_PRODUCTION): ProviderRow => ({
|
||||
id,
|
||||
@@ -40,3 +49,25 @@ describe('certificate accounts (#206)', () => {
|
||||
expect(challengeOf('tls', 'TlsAlpn01')).toBe('TlsAlpn01');
|
||||
});
|
||||
});
|
||||
|
||||
describe('the names an automatic domain orders today', () => {
|
||||
const providers = [
|
||||
row('alpn', 'TlsAlpn01'),
|
||||
row('http', 'Http01'),
|
||||
row('dns', 'Dns01'),
|
||||
row('persist', 'DnsPersist01'),
|
||||
];
|
||||
|
||||
it('follows the domain’s account, not whether its DNS is automatic', () => {
|
||||
// A TLS-ALPN account on a domain whose DNS the server manages: the technical names, no wildcard.
|
||||
expect(orderingMethod('alpn', true, providers)).toBe('tls');
|
||||
expect(orderingMethod('http', true, providers)).toBe('tls');
|
||||
expect(orderingMethod('dns', false, providers)).toBe('dns');
|
||||
expect(orderingMethod('persist', false, providers)).toBe('dns');
|
||||
});
|
||||
|
||||
it('guesses from the DNS setting only when the account is missing', () => {
|
||||
expect(orderingMethod(undefined, true, providers)).toBe('dns');
|
||||
expect(orderingMethod('gone', false, providers)).toBe('tls');
|
||||
});
|
||||
});
|
||||
@@ -46,6 +46,24 @@ export function providerFor(
|
||||
return providers.find((p) => p.directory === directory && p.challengeType === challengeOf(method, direct));
|
||||
}
|
||||
|
||||
/**
|
||||
* How a domain that's already ordered automatically gets its names checked,
|
||||
* from its own Let’s Encrypt account. The server goes by the account's
|
||||
* challenge (common/src/network/acme/order.rs): DNS-01 orders the domain and
|
||||
* a wildcard, anything else the technical names. Whether the domain's DNS is
|
||||
* managed automatically doesn't decide it, so it's only the guess when the
|
||||
* account can't be found.
|
||||
*/
|
||||
export function orderingMethod(
|
||||
providerId: string | undefined,
|
||||
dnsAutomatic: boolean,
|
||||
providers: ProviderRow[],
|
||||
): Method {
|
||||
const provider = providers.find((p) => p.id === providerId);
|
||||
if (!provider) return dnsAutomatic ? 'dns' : 'tls';
|
||||
return provider.challengeType === 'Dns01' || provider.challengeType === 'DnsPersist01' ? 'dns' : 'tls';
|
||||
}
|
||||
|
||||
export interface DomainRow {
|
||||
id: string;
|
||||
name: string;
|
||||
|
||||
Reference in new issue
Block a user