Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Address PR comments for intermediate CA issuance

Carlos Monastyrski68fbde164376
diff --git a/backend/src/db/migrations/20260113145337_add-ca-settings-to-certificate-templates-v2.ts b/backend/src/db/migrations/20260113145337_add-ca-settings-to-certificate-templates-v2.ts
index 90990a2dec..376f7f47a7 100644
--- a/backend/src/db/migrations/20260113145337_add-ca-settings-to-certificate-templates-v2.ts
+++ b/backend/src/db/migrations/20260113145337_add-ca-settings-to-certificate-templates-v2.ts
@@ -3,33 +3,45 @@ import { Knex } from "knex";
import { TableName } from "../schemas";
export async function up(knex: Knex): Promise<void> {
- const hasTemplateCaSettingsColumn = await knex.schema.hasColumn(TableName.PkiCertificatePolicy, "caSettings");
- if (!hasTemplateCaSettingsColumn) {
+ const hasTemplateBasicConstraintsColumn = await knex.schema.hasColumn(
+ TableName.PkiCertificatePolicy,
+ "basicConstraints"
+ );
+ if (!hasTemplateBasicConstraintsColumn) {
await knex.schema.alterTable(TableName.PkiCertificatePolicy, (t) => {
- t.jsonb("caSettings");
+ t.jsonb("basicConstraints");
});
}
- const hasRequestCaSettingsColumn = await knex.schema.hasColumn(TableName.CertificateRequests, "caSettings");
- if (!hasRequestCaSettingsColumn) {
+ const hasRequestBasicConstraintsColumn = await knex.schema.hasColumn(
+ TableName.CertificateRequests,
+ "basicConstraints"
+ );
+ if (!hasRequestBasicConstraintsColumn) {
await knex.schema.alterTable(TableName.CertificateRequests, (t) => {
- t.jsonb("caSettings");
+ t.jsonb("basicConstraints");
});
}
}
export async function down(knex: Knex): Promise<void> {
- const hasTemplateCaSettingsColumn = await knex.schema.hasColumn(TableName.PkiCertificatePolicy, "caSettings");
- if (hasTemplateCaSettingsColumn) {
+ const hasTemplateBasicConstraintsColumn = await knex.schema.hasColumn(
+ TableName.PkiCertificatePolicy,
+ "basicConstraints"
+ );
+ if (hasTemplateBasicConstraintsColumn) {
await knex.schema.alterTable(TableName.PkiCertificatePolicy, (t) => {
- t.dropColumn("caSettings");
+ t.dropColumn("basicConstraints");
});
}
- const hasRequestCaSettingsColumn = await knex.schema.hasColumn(TableName.CertificateRequests, "caSettings");
- if (hasRequestCaSettingsColumn) {
+ const hasRequestBasicConstraintsColumn = await knex.schema.hasColumn(
+ TableName.CertificateRequests,
+ "basicConstraints"
+ );
+ if (hasRequestBasicConstraintsColumn) {
await knex.schema.alterTable(TableName.CertificateRequests, (t) => {
- t.dropColumn("caSettings");
+ t.dropColumn("basicConstraints");
});
}
}
diff --git a/backend/src/db/schemas/certificate-requests.ts b/backend/src/db/schemas/certificate-requests.ts
index 02c98077cc..3c88cb88ea 100644
--- a/backend/src/db/schemas/certificate-requests.ts
+++ b/backend/src/db/schemas/certificate-requests.ts
@@ -28,7 +28,7 @@ export const CertificateRequestsSchema = z.object({
errorMessage: z.string().nullable().optional(),
metadata: z.string().nullable().optional(),
acmeOrderId: z.string().uuid().nullable().optional(),
- caSettings: z.unknown().nullable().optional()
+ basicConstraints: z.unknown().nullable().optional()
});
export type TCertificateRequests = z.infer<typeof CertificateRequestsSchema>;
diff --git a/backend/src/db/schemas/pki-certificate-policies.ts b/backend/src/db/schemas/pki-certificate-policies.ts
index ff378e2ebb..0269007fef 100644
--- a/backend/src/db/schemas/pki-certificate-policies.ts
+++ b/backend/src/db/schemas/pki-certificate-policies.ts
@@ -20,7 +20,7 @@ export const PkiCertificatePoliciesSchema = z.object({
validity: z.unknown().nullable().optional(),
createdAt: z.date(),
updatedAt: z.date(),
- caSettings: z.unknown().nullable().optional()
+ basicConstraints: z.unknown().nullable().optional()
});
export type TPkiCertificatePolicies = z.infer<typeof PkiCertificatePoliciesSchema>;
diff --git a/backend/src/db/schemas/pki-certificate-templates-v2.ts b/backend/src/db/schemas/pki-certificate-templates-v2.ts
index 580c2565b6..574efb2d7f 100644
--- a/backend/src/db/schemas/pki-certificate-templates-v2.ts
+++ b/backend/src/db/schemas/pki-certificate-templates-v2.ts
@@ -20,7 +20,7 @@ export const PkiCertificateTemplatesV2Schema = z.object({
validity: z.unknown().nullable().optional(),
createdAt: z.date(),
updatedAt: z.date(),
- caSettings: z.unknown().nullable().optional()
+ basicConstraints: z.unknown().nullable().optional()
});
export type TPkiCertificateTemplatesV2 = z.infer<typeof PkiCertificateTemplatesV2Schema>;
diff --git a/backend/src/server/routes/v1/certificate-policy-router.ts b/backend/src/server/routes/v1/certificate-policy-router.ts
index 417e531ac2..f4a0cac149 100644
--- a/backend/src/server/routes/v1/certificate-policy-router.ts
+++ b/backend/src/server/routes/v1/certificate-policy-router.ts
@@ -9,6 +9,7 @@ import { AuthMode } from "@app/services/auth/auth-type";
import {
CertExtendedKeyUsageType,
CertKeyUsageType,
+ CertPolicyState,
CertSubjectAlternativeNameType,
CertSubjectAttributeType
} from "@app/services/certificate-common/certificate-constants";
@@ -115,8 +116,9 @@ const policyAlgorithmsSchema = z.object({
keyAlgorithm: z.array(z.string()).min(1, "At least one key algorithm must be provided").optional()
});
-const policyCaSettingsSchema = z
+const policyBasicConstraintsSchema = z
.object({
+ isCA: z.nativeEnum(CertPolicyState).optional(),
maxPathLength: z
.number()
.int("Path length must be an integer")
@@ -135,7 +137,7 @@ const createCertificatePolicySchema = z.object({
extendedKeyUsages: policyExtendedKeyUsagesSchema.optional(),
algorithms: policyAlgorithmsSchema.optional(),
validity: policyValiditySchema.optional(),
- caSettings: policyCaSettingsSchema.optional()
+ basicConstraints: policyBasicConstraintsSchema.optional()
});
const updateCertificatePolicySchema = z.object({
@@ -147,7 +149,7 @@ const updateCertificatePolicySchema = z.object({
extendedKeyUsages: policyExtendedKeyUsagesSchema.optional(),
algorithms: policyAlgorithmsSchema.optional(),
validity: policyValiditySchema.optional(),
- caSettings: policyCaSettingsSchema.optional()
+ basicConstraints: policyBasicConstraintsSchema.optional()
});
export const registerCertificatePolicyRouter = async (server: FastifyZodProvider) => {
diff --git a/backend/src/server/routes/v1/certificate-router.ts b/backend/src/server/routes/v1/certificate-router.ts
index 0f21ca77c5..9ba52f7760 100644
--- a/backend/src/server/routes/v1/certificate-router.ts
+++ b/backend/src/server/routes/v1/certificate-router.ts
@@ -514,11 +514,6 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {
.object({
profileId: z.string().uuid(),
commonName: validateTemplateRegexField.optional(),
- organization: validateTemplateRegexField.optional(),
- organizationalUnit: validateTemplateRegexField.optional(),
- country: validateTemplateRegexField.optional(),
- state: validateTemplateRegexField.optional(),
- locality: validateTemplateRegexField.optional(),
ttl: z
.string()
.trim()
@@ -563,11 +558,6 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {
handler: async (req) => {
const certificateRequestForService: CertificateRequestForService = {
commonName: req.body.commonName,
- organization: req.body.organization,
- organizationalUnit: req.body.organizationalUnit,
- country: req.body.country,
- state: req.body.state,
- locality: req.body.locality,
keyUsages: req.body.keyUsages,
extendedKeyUsages: req.body.extendedKeyUsages,
altNames: req.body.altNames,
diff --git a/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts b/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts
index 5059c3eb57..d53423c61a 100644
--- a/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts
+++ b/backend/src/services/certificate-authority/internal/internal-certificate-authority-service.ts
@@ -149,22 +149,22 @@ export const internalCertificateAuthorityServiceFactory = ({
* This handles both policy-level validation and issuing CA hierarchy validation.
*/
const $createBasicConstraintsExtension = ({
- caSettings,
+ basicConstraints,
pathLength,
caCertObj
}: {
- caSettings?: { maxPathLength?: number } | null;
+ basicConstraints?: { maxPathLength?: number } | null;
pathLength?: number | null;
caCertObj: x509.X509Certificate;
}): x509.BasicConstraintsExtension => {
- const shouldIssueCaCertificate = caSettings !== undefined && caSettings !== null;
+ const shouldIssueCaCertificate = basicConstraints !== undefined && basicConstraints !== null;
if (!shouldIssueCaCertificate) {
return new x509.BasicConstraintsExtension(false);
}
// Validate against policy's maxPathLength
- const policyMaxPathLength = caSettings.maxPathLength;
+ const policyMaxPathLength = basicConstraints.maxPathLength;
if (policyMaxPathLength !== undefined && policyMaxPathLength !== null && policyMaxPathLength !== -1) {
if (pathLength === undefined || pathLength === null) {
throw new BadRequestError({
@@ -1273,7 +1273,7 @@ export const internalCertificateAuthorityServiceFactory = ({
keyAlgorithm,
isFromProfile,
internal = false,
- caSettings,
+ basicConstraints,
pathLength,
organization,
country,
@@ -1442,7 +1442,7 @@ export const internalCertificateAuthorityServiceFactory = ({
const caIssuerUrl = `${appCfg.SITE_URL}/api/v1/cert-manager/ca/internal/${ca.id}/certificates/${caCert.id}/der`;
const basicConstraintsExtension = $createBasicConstraintsExtension({
- caSettings,
+ basicConstraints,
pathLength,
caCertObj
});
@@ -1673,7 +1673,7 @@ export const internalCertificateAuthorityServiceFactory = ({
extendedKeyUsages,
signatureAlgorithm,
keyAlgorithm,
- caSettings,
+ basicConstraints,
pathLength,
tx
} = dto;
@@ -1816,7 +1816,7 @@ export const internalCertificateAuthorityServiceFactory = ({
const caIssuerUrl = `${appCfg.SITE_URL}/api/v1/cert-manager/ca/internal/${ca.id}/certificates/${caCert.id}/der`;
const basicConstraintsExtension = $createBasicConstraintsExtension({
- caSettings,
+ basicConstraints,
pathLength,
caCertObj
});
diff --git a/backend/src/services/certificate-authority/internal/internal-certificate-authority-types.ts b/backend/src/services/certificate-authority/internal/internal-certificate-authority-types.ts
index 4ef5e07537..178d56e59c 100644
--- a/backend/src/services/certificate-authority/internal/internal-certificate-authority-types.ts
+++ b/backend/src/services/certificate-authority/internal/internal-certificate-authority-types.ts
@@ -121,7 +121,7 @@ export type TImportCertToCaDTO = {
certificateChain: string;
} & Omit<TProjectPermission, "projectId">;
-export type TCaSettings = {
+export type TBasicConstraints = {
maxPathLength?: number;
} | null;
@@ -142,7 +142,7 @@ export type TIssueCertFromCaDTO = {
isFromProfile?: boolean;
profileId?: string;
internal?: boolean;
- caSettings?: TCaSettings;
+ basicConstraints?: TBasicConstraints;
pathLength?: number | null;
organization?: string;
country?: string;
@@ -171,7 +171,7 @@ export type TSignCertFromCaDTO =
keyAlgorithm?: string;
isFromProfile?: boolean;
profileId?: string;
- caSettings?: TCaSettings;
+ basicConstraints?: TBasicConstraints;
pathLength?: number | null;
tx?: Knex;
}
@@ -193,7 +193,7 @@ export type TSignCertFromCaDTO =
keyAlgorithm?: string;
isFromProfile?: boolean;
profileId?: string;
- caSettings?: TCaSettings;
+ basicConstraints?: TBasicConstraints;
pathLength?: number | null;
tx?: Knex;
} & Omit<TProjectPermission, "projectId">);
diff --git a/backend/src/services/certificate-common/certificate-constants.ts b/backend/src/services/certificate-common/certificate-constants.ts
index 329617bf00..498dbae9cf 100644
--- a/backend/src/services/certificate-common/certificate-constants.ts
+++ b/backend/src/services/certificate-common/certificate-constants.ts
@@ -43,6 +43,12 @@ export enum CertSanEffect {
REQUIRE = "require"
}
+export enum CertPolicyState {
+ ALLOWED = "allowed",
+ REQUIRED = "required",
+ DENIED = "denied"
+}
+
export enum CertDurationUnit {
DAYS = "days",
MONTHS = "months",
@@ -208,5 +214,6 @@ export const DURATION_UNIT_OPTIONS = Object.values(CertDurationUnit);
export const SUBJECT_ATTRIBUTE_TYPE_OPTIONS = Object.values(CertSubjectAttributeType);
export const ATTRIBUTE_RULE_OPTIONS = Object.values(CertAttributeRule);
export const SAN_EFFECT_OPTIONS = Object.values(CertSanEffect);
+export const POLICY_STATE_OPTIONS = Object.values(CertPolicyState);
export const KEY_ALGORITHM_OPTIONS = Object.values(CertKeyAlgorithm);
export const SIGNATURE_ALGORITHM_OPTIONS = Object.values(CertSignatureAlgorithm);
diff --git a/backend/src/services/certificate-est-v3/certificate-est-v3-service.test.ts b/backend/src/services/certificate-est-v3/certificate-est-v3-service.test.ts
index 55e6fe81ce..6f483f7b7d 100644
--- a/backend/src/services/certificate-est-v3/certificate-est-v3-service.test.ts
+++ b/backend/src/services/certificate-est-v3/certificate-est-v3-service.test.ts
@@ -174,7 +174,7 @@ describe("CertificateEstV3Service Security Fix", () => {
const mockCertificatePolicyDAL = {
findById: vi.fn().mockResolvedValue({
id: "policy-123",
- caSettings: null,
+ basicConstraints: null,
subject: [],
sans: []
})
@@ -540,8 +540,7 @@ describe("CertificateEstV3Service Security Fix", () => {
caId: "ca-123",
csr: basicCSR,
isFromProfile: true,
- caSettings: null,
- pathLength: undefined
+ basicConstraints: undefined
});
});
@@ -721,8 +720,7 @@ describe("CertificateEstV3Service Security Fix", () => {
caId: "ca-123",
isFromProfile: true,
csr: basicCSR,
- caSettings: null,
- pathLength: undefined
+ basicConstraints: undefined
});
});
diff --git a/backend/src/services/certificate-est-v3/certificate-est-v3-service.ts b/backend/src/services/certificate-est-v3/certificate-est-v3-service.ts
index 8a2317acb0..b1e6b68b12 100644
--- a/backend/src/services/certificate-est-v3/certificate-est-v3-service.ts
+++ b/backend/src/services/certificate-est-v3/certificate-est-v3-service.ts
@@ -7,6 +7,7 @@ import { TCertificateAuthorityCertDALFactory } from "@app/services/certificate-a
import { TCertificateAuthorityDALFactory } from "@app/services/certificate-authority/certificate-authority-dal";
import { getCaCertChain, getCaCertChains } from "@app/services/certificate-authority/certificate-authority-fns";
import { TInternalCertificateAuthorityServiceFactory } from "@app/services/certificate-authority/internal/internal-certificate-authority-service";
+import { CertPolicyState } from "@app/services/certificate-common/certificate-constants";
import { extractCertificateRequestFromCSR } from "@app/services/certificate-common/certificate-csr-utils";
import { mapEnumsForValidation } from "@app/services/certificate-common/certificate-utils";
import { TCertificatePolicyServiceFactory } from "@app/services/certificate-policy/certificate-policy-service";
@@ -146,16 +147,36 @@ export const certificateEstV3ServiceFactory = ({
});
}
- // Fetch the policy to get caSettings for CA certificate support
+ // Fetch the policy to get basicConstraints for CA certificate support
const policy = await certificatePolicyDAL.findById(profile.certificatePolicyId);
+ const csrRequestsCA = certificateRequest.basicConstraints?.isCA === true;
+ const policyIsCAState: CertPolicyState =
+ (policy?.basicConstraints?.isCA as CertPolicyState) || CertPolicyState.DENIED;
+
+ if (csrRequestsCA && policyIsCAState === CertPolicyState.DENIED) {
+ throw new BadRequestError({
+ message:
+ "CA certificate issuance is not allowed by this policy. The policy's basicConstraints must be set to 'allowed' or 'required'."
+ });
+ }
+
+ if (policyIsCAState === CertPolicyState.REQUIRED && !csrRequestsCA) {
+ throw new BadRequestError({
+ message:
+ "CA certificate issuance is required by this policy. The CSR must include basicConstraints with CA:TRUE."
+ });
+ }
+
+ const caBasicConstraints = csrRequestsCA ? { maxPathLength: policy?.basicConstraints?.maxPathLength } : undefined;
+
const { certificate } = await internalCertificateAuthorityService.signCertFromCa({
isInternal: true,
caId: profile.caId,
csr,
isFromProfile: true,
- // Pass CA settings from policy (null for leaf certificates, object for CA certificates)
- caSettings: policy?.caSettings
+ // Pass CA settings to the CA service (undefined for leaf certificates, object for CA certificates)
+ basicConstraints: caBasicConstraints
});
return convertRawCertsToPkcs7([certificate.rawData]);
@@ -277,16 +298,38 @@ export const certificateEstV3ServiceFactory = ({
});
}
- // Fetch the policy to get caSettings for CA certificate support
+ // Fetch the policy to get basicConstraints for CA certificate support
const policy = await certificatePolicyDAL.findById(profile.certificatePolicyId);
+ // Check if the CSR requests CA certificate
+ const csrRequestsCA = certificateRequest.basicConstraints?.isCA === true;
+ const policyIsCAState: CertPolicyState =
+ (policy?.basicConstraints?.isCA as CertPolicyState) || CertPolicyState.DENIED;
+
+ // Validate CA request against policy
+ if (csrRequestsCA && policyIsCAState === CertPolicyState.DENIED) {
+ throw new BadRequestError({
+ message:
+ "CA certificate issuance is not allowed by this policy. The policy's basicConstraints must be set to 'allowed' or 'required'."
+ });
+ }
+
+ if (policyIsCAState === CertPolicyState.REQUIRED && !csrRequestsCA) {
+ throw new BadRequestError({
+ message:
+ "CA certificate issuance is required by this policy. The CSR must include basicConstraints with CA:TRUE."
+ });
+ }
+
+ const caBasicConstraints = csrRequestsCA ? { maxPathLength: policy?.basicConstraints?.maxPathLength } : undefined;
+
const { certificate } = await internalCertificateAuthorityService.signCertFromCa({
isInternal: true,
caId: profile.caId,
csr,
isFromProfile: true,
- // Pass CA settings from policy (null for leaf certificates, object for CA certificates)
- caSettings: policy?.caSettings
+ // Pass CA settings to the CA service (undefined for leaf certificates, object for CA certificates)
+ basicConstraints: caBasicConstraints
});
return convertRawCertsToPkcs7([certificate.rawData]);
diff --git a/backend/src/services/certificate-policy/certificate-policy-dal.ts b/backend/src/services/certificate-policy/certificate-policy-dal.ts
index e7a6fbaf82..4110c93f0d 100644
--- a/backend/src/services/certificate-policy/certificate-policy-dal.ts
+++ b/backend/src/services/certificate-policy/certificate-policy-dal.ts
@@ -23,7 +23,15 @@ export const certificatePolicyDALFactory = (db: TDbClient) => {
const serializeJsonFields = (data: TCertificatePolicyInsert | TCertificatePolicyUpdate) => {
const serialized = { ...data } as Record<string, unknown>;
- const jsonFields = ["subject", "sans", "keyUsages", "extendedKeyUsages", "algorithms", "validity", "caSettings"];
+ const jsonFields = [
+ "subject",
+ "sans",
+ "keyUsages",
+ "extendedKeyUsages",
+ "algorithms",
+ "validity",
+ "basicConstraints"
+ ];
jsonFields.forEach((field) => {
const value = serialized[field];
@@ -36,7 +44,15 @@ export const certificatePolicyDALFactory = (db: TDbClient) => {
};
const parseJsonFields = (raw: Record<string, unknown>): TCertificatePolicy => {
- const jsonFields = ["subject", "sans", "keyUsages", "extendedKeyUsages", "algorithms", "validity", "caSettings"];
+ const jsonFields = [
+ "subject",
+ "sans",
+ "keyUsages",
+ "extendedKeyUsages",
+ "algorithms",
+ "validity",
+ "basicConstraints"
+ ];
const parsed = { ...raw } as Record<string, unknown>;
jsonFields.forEach((field) => {
diff --git a/backend/src/services/certificate-policy/certificate-policy-schemas.ts b/backend/src/services/certificate-policy/certificate-policy-schemas.ts
index 9d93092899..34f7289cd7 100644
--- a/backend/src/services/certificate-policy/certificate-policy-schemas.ts
+++ b/backend/src/services/certificate-policy/certificate-policy-schemas.ts
@@ -4,6 +4,7 @@ import { z } from "zod";
import {
CertExtendedKeyUsageType,
CertKeyUsageType,
+ CertPolicyState,
CertSubjectAlternativeNameType,
CertSubjectAttributeType
} from "@app/services/certificate-common/certificate-constants";
@@ -105,8 +106,9 @@ const policyAlgorithmsSchema = z.object({
.optional()
});
-export const policyCaSettingsSchema = z
+export const policyBasicConstraintsSchema = z
.object({
+ isCA: z.nativeEnum(CertPolicyState).optional(),
maxPathLength: z
.number()
.int("Path length must be an integer")
@@ -131,7 +133,7 @@ export const certificatePolicyResponseSchema = z.object({
extendedKeyUsages: policyExtendedKeyUsagesSchema.optional(),
algorithms: policyAlgorithmsSchema.optional(),
validity: policyValiditySchema.optional(),
- caSettings: policyCaSettingsSchema.optional(),
+ basicConstraints: policyBasicConstraintsSchema.optional(),
createdAt: z.date(),
updatedAt: z.date()
});
diff --git a/backend/src/services/certificate-policy/certificate-policy-service.ts b/backend/src/services/certificate-policy/certificate-policy-service.ts
index 60ca0ba3c4..8fb023c422 100644
--- a/backend/src/services/certificate-policy/certificate-policy-service.ts
+++ b/backend/src/services/certificate-policy/certificate-policy-service.ts
@@ -13,7 +13,7 @@ import { ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
import { alphaNumericNanoId } from "@app/lib/nanoid";
import { ActorAuthMethod, ActorType } from "../auth/auth-type";
-import { CertSubjectAttributeType } from "../certificate-common/certificate-constants";
+import { CertPolicyState, CertSubjectAttributeType } from "../certificate-common/certificate-constants";
import { TCertificatePolicyDALFactory } from "./certificate-policy-dal";
import {
TCertificatePolicy,
@@ -602,26 +602,36 @@ export const certificatePolicyServiceFactory = ({
}
}
- if (request.basicConstraints?.isCA) {
- if (!template.caSettings) {
+ const isCaPolicy: CertPolicyState = (template.basicConstraints?.isCA as CertPolicyState) || CertPolicyState.DENIED;
+ const requestWantsCA = request.basicConstraints?.isCA === true;
+
+ if (isCaPolicy === CertPolicyState.DENIED) {
+ if (requestWantsCA) {
errors.push(
- "CA certificate issuance is not allowed by this policy. The policy must have caSettings configured to issue CA certificates."
+ "CA certificate issuance is denied by this policy. The policy does not allow issuing CA certificates."
);
- } else {
- const { maxPathLength } = template.caSettings;
-
- if (maxPathLength !== undefined && maxPathLength !== null && maxPathLength !== -1) {
- if (request.basicConstraints.pathLength === undefined || request.basicConstraints.pathLength === null) {
- errors.push(
- `Path length is required when issuing CA certificates. Policy allows maximum path length of ${maxPathLength}.`
- );
- } else if (request.basicConstraints.pathLength > maxPathLength) {
- errors.push(
- `Requested path length (${request.basicConstraints.pathLength}) exceeds maximum allowed by policy (${maxPathLength}).`
- );
- } else if (request.basicConstraints.pathLength < 0 && request.basicConstraints.pathLength !== -1) {
- errors.push("Path length must be -1 (unlimited), 0, or a positive integer.");
- }
+ }
+ } else if (isCaPolicy === CertPolicyState.REQUIRED) {
+ if (!requestWantsCA) {
+ errors.push(
+ "CA certificate issuance is required by this policy. The request must include basicConstraints with isCA set to true."
+ );
+ }
+ }
+ if (requestWantsCA && isCaPolicy !== CertPolicyState.DENIED) {
+ const { maxPathLength } = template.basicConstraints || {};
+
+ if (maxPathLength !== undefined && maxPathLength !== null && maxPathLength !== -1) {
+ if (request.basicConstraints?.pathLength === undefined || request.basicConstraints?.pathLength === null) {
+ errors.push(
+ `Path length is required when issuing CA certificates. Policy allows maximum path length of ${maxPathLength}.`
+ );
+ } else if (request.basicConstraints.pathLength > maxPathLength) {
+ errors.push(
+ `Requested path length (${request.basicConstraints.pathLength}) exceeds maximum allowed by policy (${maxPathLength}).`
+ );
+ } else if (request.basicConstraints.pathLength < 0 && request.basicConstraints.pathLength !== -1) {
+ errors.push("Path length must be -1 (unlimited), 0, or a positive integer.");
}
}
}
diff --git a/backend/src/services/certificate-policy/certificate-policy-types.ts b/backend/src/services/certificate-policy/certificate-policy-types.ts
index a36612d1bf..1b4c9c69a5 100644
--- a/backend/src/services/certificate-policy/certificate-policy-types.ts
+++ b/backend/src/services/certificate-policy/certificate-policy-types.ts
@@ -2,11 +2,15 @@ import { TPkiCertificatePolicies, TPkiCertificatePoliciesInsert } from "@app/db/
import {
CertExtendedKeyUsageType,
CertKeyUsageType,
+ CertPolicyState,
CertSubjectAlternativeNameType,
CertSubjectAttributeType
} from "@app/services/certificate-common/certificate-constants";
-export interface TCaSettings {
+export type TBasicConstraintsIsCAPolicy = CertPolicyState;
+
+export interface TBasicConstraints {
+ isCA?: TBasicConstraintsIsCAPolicy;
maxPathLength?: number; // -1 = unlimited, 0+ = specific limit, undefined = not constrained
}
@@ -49,7 +53,7 @@ export type TCertificatePolicy = TPkiCertificatePolicies & {
extendedKeyUsages?: TTemplateV2Policy["extendedKeyUsages"];
algorithms?: TTemplateV2Policy["algorithms"];
validity?: TTemplateV2Policy["validity"];
- caSettings?: TCaSettings | null;
+ basicConstraints?: TBasicConstraints | null;
};
export type TCertificatePolicyInsert = TPkiCertificatePoliciesInsert & {
@@ -59,7 +63,7 @@ export type TCertificatePolicyInsert = TPkiCertificatePoliciesInsert & {
extendedKeyUsages?: TTemplateV2Policy["extendedKeyUsages"];
algorithms?: TTemplateV2Policy["algorithms"];
validity?: TTemplateV2Policy["validity"];
- caSettings?: TCaSettings | null;
+ basicConstraints?: TBasicConstraints | null;
};
export type TCertificatePolicyUpdate = Partial<
@@ -73,7 +77,7 @@ export type TCertificatePolicyUpdate = Partial<
| "extendedKeyUsages"
| "algorithms"
| "validity"
- | "caSettings"
+ | "basicConstraints"
>
>;
diff --git a/backend/src/services/certificate-request/certificate-request-service.ts b/backend/src/services/certificate-request/certificate-request-service.ts
index 02b4232878..685efeebb7 100644
--- a/backend/src/services/certificate-request/certificate-request-service.ts
+++ b/backend/src/services/certificate-request/certificate-request-service.ts
@@ -50,7 +50,7 @@ const certificateRequestDataSchema = z
signatureAlgorithm: z.string().max(100).optional(),
metadata: z.string().max(2000).optional(),
certificateId: z.string().optional(),
- caSettings: z
+ basicConstraints: z
.object({
isCA: z.boolean(),
pathLength: z.number().int().min(-1).optional()
@@ -81,7 +81,7 @@ const certificateRequestDataSchema = z
.refine(
(data) => {
// pathLength should only be set when isCA is true
- if (data.caSettings?.pathLength !== undefined && !data.caSettings?.isCA) {
+ if (data.basicConstraints?.pathLength !== undefined && !data.basicConstraints?.isCA) {
return false;
}
return true;
diff --git a/backend/src/services/certificate-request/certificate-request-types.ts b/backend/src/services/certificate-request/certificate-request-types.ts
index 5ad685834b..db9a12f8d8 100644
--- a/backend/src/services/certificate-request/certificate-request-types.ts
+++ b/backend/src/services/certificate-request/certificate-request-types.ts
@@ -22,7 +22,7 @@ export type TCreateCertificateRequestDTO = TProjectPermission & {
status: CertificateRequestStatus;
certificateId?: string;
acmeOrderId?: string;
- caSettings?: {
+ basicConstraints?: {
isCA: boolean;
pathLength?: number;
};
diff --git a/backend/src/services/certificate-v3/certificate-v3-service.ts b/backend/src/services/certificate-v3/certificate-v3-service.ts
index ad6f197a33..9b8f525ea4 100644
--- a/backend/src/services/certificate-v3/certificate-v3-service.ts
+++ b/backend/src/services/certificate-v3/certificate-v3-service.ts
@@ -48,6 +48,7 @@ import { getProjectKmsCertificateKeyId } from "@app/services/project/project-fns
import {
CertExtendedKeyUsageType,
CertKeyUsageType,
+ CertPolicyState,
CertSubjectAlternativeNameType,
mapLegacyExtendedKeyUsageToStandard,
mapLegacyKeyUsageToStandard
@@ -1052,12 +1053,18 @@ export const certificateV3ServiceFactory = ({
validateAlgorithmCompatibility(ca, policy);
const shouldIssueAsCA = certificateRequest.basicConstraints?.isCA === true;
- if (shouldIssueAsCA && !policy.caSettings) {
+ const policyIsCAState: CertPolicyState =
+ (policy.basicConstraints?.isCA as CertPolicyState) || CertPolicyState.DENIED;
+
+ if (shouldIssueAsCA && policyIsCAState === CertPolicyState.DENIED) {
throw new BadRequestError({
- message: "CA certificate issuance is not allowed by this policy. The policy must have caSettings configured."
+ message:
+ "CA certificate issuance is not allowed by this policy. The policy's basicConstraints must be set to 'allowed' or 'required'."
});
}
+ const caBasicConstraints = shouldIssueAsCA ? { maxPathLength: policy.basicConstraints?.maxPathLength } : undefined;
+
const {
certificate,
certificateChain,
@@ -1072,7 +1079,7 @@ export const certificateV3ServiceFactory = ({
friendlyName: certificateSubject.common_name || "Certificate",
commonName: certificateSubject.common_name || "",
altNames: subjectAlternativeNames,
- caSettings: shouldIssueAsCA ? policy.caSettings : undefined,
+ basicConstraints: caBasicConstraints,
pathLength: certificateRequest.basicConstraints?.pathLength,
ttl: certificateRequest.validity.ttl,
keyUsages: convertKeyUsageArrayToLegacy(certificateRequest.keyUsages) || [],
@@ -1125,7 +1132,7 @@ export const certificateV3ServiceFactory = ({
signatureAlgorithm: effectiveSignatureAlgorithm,
status: CertificateRequestStatus.ISSUED,
certificateId: certResult.certificateId,
- caSettings: certificateRequest.basicConstraints
+ basicConstraints: certificateRequest.basicConstraints
});
return { ...certResult, cert: certificateRecord, certificateRequestId: certRequestResult.id };
@@ -1246,19 +1253,26 @@ export const certificateV3ServiceFactory = ({
const effectiveKeyAlgorithm = extractedKeyAlgorithm;
const shouldIssueAsCA = basicConstraints?.isCA === true;
- if (shouldIssueAsCA && !policy.caSettings) {
+ const policyIsCAState: CertPolicyState =
+ (policy.basicConstraints?.isCA as CertPolicyState) || CertPolicyState.DENIED;
+
+ if (shouldIssueAsCA && policyIsCAState === CertPolicyState.DENIED) {
throw new BadRequestError({
- message: "CA certificate issuance is not allowed by this policy. The policy must have caSettings configured."
+ message:
+ "CA certificate issuance is not allowed by this policy. The policy's basicConstraints must be set to 'allowed' or 'required'."
});
}
+ // Transform policy basicConstraints to the format expected by the CA service
+ const caBasicConstraints = shouldIssueAsCA ? { maxPathLength: policy.basicConstraints?.maxPathLength } : undefined;
+
const { certificate, certificateChain, issuingCaCertificate, serialNumber, cert, certificateRequestId } =
await certificateDAL.transaction(async (tx) => {
const certResult = await internalCaService.signCertFromCa({
isInternal: true,
caId: ca.id,
csr,
- caSettings: shouldIssueAsCA ? policy.caSettings : undefined,
+ basicConstraints: caBasicConstraints,
pathLength: basicConstraints?.pathLength,
ttl: validity.ttl,
altNames: undefined,
@@ -1307,7 +1321,7 @@ export const certificateV3ServiceFactory = ({
signatureAlgorithm: effectiveSignatureAlgorithm,
status: CertificateRequestStatus.ISSUED,
certificateId: certResult.certificateId,
- caSettings: basicConstraints
+ basicConstraints
});
return { ...certResult, cert: signedCertRecord, certificateRequestId: certRequestResult.id };
diff --git a/frontend/src/hooks/api/certificatePolicies/types.ts b/frontend/src/hooks/api/certificatePolicies/types.ts
index 20646bae3b..97961fa381 100644
--- a/frontend/src/hooks/api/certificatePolicies/types.ts
+++ b/frontend/src/hooks/api/certificatePolicies/types.ts
@@ -30,10 +30,15 @@ export type TCertificatePolicyRule = {
validity?: {
max?: string;
};
- caSettings?: TCaSettings;
+ basicConstraints?: TBasicConstraints;
};
-export type TCaSettings = {
+import { CertPolicyState } from "@app/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants";
+
+export type TBasicConstraintsIsCAPolicy = CertPolicyState;
+
+export type TBasicConstraints = {
+ isCA?: TBasicConstraintsIsCAPolicy;
maxPathLength?: number;
} | null;
@@ -50,7 +55,7 @@ export type TCertificatePolicy = {
validity?: TCertificatePolicyRule["validity"];
createdAt: string;
updatedAt: string;
- caSettings?: TCaSettings | null;
+ basicConstraints?: TBasicConstraints | null;
};
export type TCreateCertificatePolicyDTO = {
@@ -63,7 +68,7 @@ export type TCreateCertificatePolicyDTO = {
extendedKeyUsages?: TCertificatePolicyRule["extendedKeyUsages"];
algorithms?: TCertificatePolicyRule["algorithms"];
validity?: TCertificatePolicyRule["validity"];
- caSettings?: TCaSettings;
+ basicConstraints?: TBasicConstraints;
};
export type TUpdateCertificatePolicyDTO = {
@@ -76,7 +81,7 @@ export type TUpdateCertificatePolicyDTO = {
extendedKeyUsages?: TCertificatePolicyRule["extendedKeyUsages"];
algorithms?: TCertificatePolicyRule["algorithms"];
validity?: TCertificatePolicyRule["validity"];
- caSettings?: TCaSettings;
+ basicConstraints?: TBasicConstraints;
};
export type TDeleteCertificatePolicyDTO = {
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx
index 57102efb98..5f902dac06 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx
@@ -351,10 +351,13 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }
}
}
- if (constraints.templateAllowsCA && basicConstraints?.isCA) {
+ if (
+ (constraints.templateAllowsCA && basicConstraints?.isCA) ||
+ constraints.templateRequiresCA
+ ) {
request.attributes.basicConstraints = {
isCA: true,
- pathLength: basicConstraints.pathLength ?? undefined
+ pathLength: basicConstraints?.pathLength ?? undefined
};
}
@@ -569,11 +572,14 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }
<div className="flex items-center gap-3">
<Checkbox
id="isCA"
- isChecked={value || false}
+ isChecked={constraints.templateRequiresCA || value || false}
+ isDisabled={constraints.templateRequiresCA}
onCheckedChange={(checked) => {
- onChange(checked);
- if (!checked) {
- setValue("basicConstraints.pathLength", undefined);
+ if (!constraints.templateRequiresCA) {
+ onChange(checked);
+ if (!checked) {
+ setValue("basicConstraints.pathLength", undefined);
+ }
}
}}
/>
@@ -584,7 +590,7 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }
label="Issue as Certificate Authority"
/>
<p className="text-xs text-bunker-300">
- This certificate will be issued with CA:TRUE
+ This certificate will be issued with the CA:TRUE extension
</p>
</div>
</div>
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificatePolicy.ts b/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificatePolicy.ts
index 871298193b..fef7ac2849 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificatePolicy.ts
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/useCertificatePolicy.ts
@@ -6,6 +6,7 @@ import {
KEY_USAGES_OPTIONS
} from "@app/hooks/api/certificates/constants";
import {
+ CertPolicyState,
CertSubjectAlternativeNameType,
CertSubjectAttributeType,
mapPolicyKeyAlgorithmToApi,
@@ -44,6 +45,7 @@ export type TemplateConstraints = {
shouldShowSanSection: boolean;
shouldShowSubjectSection: boolean;
templateAllowsCA: boolean;
+ templateRequiresCA: boolean;
maxPathLength?: number;
};
@@ -71,6 +73,7 @@ export const useCertificatePolicy = (
shouldShowSanSection: true,
shouldShowSubjectSection: true,
templateAllowsCA: false,
+ templateRequiresCA: false,
maxPathLength: undefined
});
@@ -122,15 +125,19 @@ export const useCertificatePolicy = (
shouldShowSanSection: true,
shouldShowSubjectSection: true,
templateAllowsCA: false,
+ templateRequiresCA: false,
maxPathLength: undefined
});
};
useEffect(() => {
if (templateData && selectedProfile && isModalOpen) {
+ const isCaPolicy =
+ (templateData.basicConstraints?.isCA as CertPolicyState) || CertPolicyState.DENIED;
const templateAllowsCA =
- templateData.caSettings !== undefined && templateData.caSettings !== null;
- const maxPathLength = templateData.caSettings?.maxPathLength;
+ isCaPolicy === CertPolicyState.ALLOWED || isCaPolicy === CertPolicyState.REQUIRED;
+ const templateRequiresCA = isCaPolicy === CertPolicyState.REQUIRED;
+ const maxPathLength = templateData.basicConstraints?.maxPathLength;
const newConstraints: TemplateConstraints = {
allowedSignatureAlgorithms: templateData.algorithms?.signature || [],
@@ -150,6 +157,7 @@ export const useCertificatePolicy = (
shouldShowSanSection: true,
shouldShowSubjectSection: true,
templateAllowsCA,
+ templateRequiresCA,
maxPathLength
};
@@ -212,6 +220,10 @@ export const useCertificatePolicy = (
setValue("keyUsages", initialKeyUsages);
setValue("extendedKeyUsages", initialExtendedKeyUsages);
+
+ if (templateRequiresCA) {
+ setValue("basicConstraints.isCA", true);
+ }
}
}, [templateData, selectedProfile, setValue, watch, isModalOpen]);
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsx
index 2c901b1923..1646ff2cc2 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsx
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsx
@@ -35,6 +35,7 @@ import {
CertDurationUnit,
CertExtendedKeyUsageType,
CertKeyUsageType,
+ CertPolicyState,
CertSanInclude,
CertSubjectAlternativeNameType,
CertSubjectAttributeInclude,
@@ -226,9 +227,9 @@ export const CreatePolicyModal = ({ isOpen, onClose, policy, mode = "create" }:
defaultKeyType: ""
};
- const basicConstraints = {
- isCA: policyData.caSettings !== undefined && policyData.caSettings !== null,
- maxPathLength: policyData.caSettings?.maxPathLength ?? undefined
+ const basicConstraints: FormData["basicConstraints"] = {
+ isCA: (policyData.basicConstraints?.isCA as CertPolicyState) || CertPolicyState.DENIED,
+ maxPathLength: policyData.basicConstraints?.maxPathLength ?? undefined
};
return {
@@ -252,7 +253,7 @@ export const CreatePolicyModal = ({ isOpen, onClose, policy, mode = "create" }:
name: "",
description: "",
basicConstraints: {
- isCA: false,
+ isCA: CertPolicyState.DENIED,
maxPathLength: undefined
},
attributes: [],
@@ -298,7 +299,7 @@ export const CreatePolicyModal = ({ isOpen, onClose, policy, mode = "create" }:
optionalUsages: []
};
const watchedPreset = watch("preset") || POLICY_PRESET_IDS.CUSTOM;
- const watchedIsCA = watch("basicConstraints.isCA") || false;
+ const watchedIsCAPolicy = watch("basicConstraints.isCA") || CertPolicyState.DENIED;
const handlePresetChange = async (presetId: PolicyPresetId) => {
setValue("preset", presetId);
@@ -328,6 +329,12 @@ export const CreatePolicyModal = ({ isOpen, onClose, policy, mode = "create" }:
if (selectedPreset.formData.keyAlgorithm) {
setValue("keyAlgorithm", selectedPreset.formData.keyAlgorithm);
}
+ if (selectedPreset.formData.basicConstraints) {
+ setValue("basicConstraints", selectedPreset.formData.basicConstraints);
+ }
+ if (selectedPreset.formData.validity) {
+ setValue("validity", selectedPreset.formData.validity);
+ }
await trigger();
}
@@ -464,11 +471,13 @@ export const CreatePolicyModal = ({ isOpen, onClose, policy, mode = "create" }:
validity.max = `${data.validity.maxDuration.value}${unit}`;
}
- const caSettings = data.basicConstraints?.isCA
- ? {
- maxPathLength: data.basicConstraints.maxPathLength ?? undefined
- }
- : null;
+ const basicConstraints =
+ data.basicConstraints?.isCA && data.basicConstraints.isCA !== CertPolicyState.DENIED
+ ? {
+ isCA: data.basicConstraints.isCA,
+ maxPathLength: data.basicConstraints.maxPathLength ?? undefined
+ }
+ : null;
return {
name: data.name,
@@ -479,7 +488,7 @@ export const CreatePolicyModal = ({ isOpen, onClose, policy, mode = "create" }:
extendedKeyUsages,
algorithms,
validity,
- caSettings
+ basicConstraints
};
};
@@ -1088,26 +1097,30 @@ export const CreatePolicyModal = ({ isOpen, onClose, policy, mode = "create" }:
name="basicConstraints.isCA"
render={({ field: { value, onChange }, fieldState: { error } }) => (
<FormControl isError={Boolean(error)} errorText={error?.message}>
- <div className="flex items-center gap-3">
- <Checkbox
- id="isCA"
- isChecked={value || false}
- onCheckedChange={(checked) => {
- onChange(checked);
- if (!checked) {
- setValue("basicConstraints.maxPathLength", undefined);
- }
- }}
- />
+ <div className="flex items-center justify-between">
<div className="space-y-1">
<span className="text-sm font-medium text-mineshaft-100">
- Allow issuance of CA certificates
+ CA Certificate Property
</span>
<p className="text-xs text-bunker-300">
- When enabled, certificates issued under this policy may be Certificate
- Authorities (CA:TRUE).
+ Controls whether certificates issued under this policy can have the
+ CA:TRUE property.
</p>
</div>
+ <Select
+ value={value || CertPolicyState.DENIED}
+ onValueChange={(newValue) => {
+ onChange(newValue);
+ if (newValue === CertPolicyState.DENIED) {
+ setValue("basicConstraints.maxPathLength", undefined);
+ }
+ }}
+ className="w-32"
+ >
+ <SelectItem value={CertPolicyState.DENIED}>Deny</SelectItem>
+ <SelectItem value={CertPolicyState.ALLOWED}>Allow</SelectItem>
+ <SelectItem value={CertPolicyState.REQUIRED}>Require</SelectItem>
+ </Select>
</div>
</FormControl>
)}
@@ -1157,7 +1170,7 @@ export const CreatePolicyModal = ({ isOpen, onClose, policy, mode = "create" }:
placeholder="Leave empty to omit the constraint"
className="w-full"
value={field.value ?? ""}
- isDisabled={!watchedIsCA}
+ isDisabled={watchedIsCAPolicy === CertPolicyState.DENIED}
onChange={(e) => {
const val = e.target.value;
if (val === "") {
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants.ts b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants.ts
index 9b6a5b2c5b..3232244e81 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants.ts
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants.ts
@@ -38,6 +38,12 @@ export enum CertSanEffect {
REQUIRE = "require"
}
+export enum CertPolicyState {
+ ALLOWED = "allowed",
+ REQUIRED = "required",
+ DENIED = "denied"
+}
+
export enum CertDurationUnit {
DAYS = "days",
MONTHS = "months",
@@ -164,6 +170,7 @@ export const DURATION_UNIT_OPTIONS = Object.values(CertDurationUnit);
export const SUBJECT_ATTRIBUTE_TYPE_OPTIONS = Object.values(CertSubjectAttributeType);
export const ATTRIBUTE_RULE_OPTIONS = Object.values(CertAttributeRule);
export const SAN_EFFECT_OPTIONS = Object.values(CertSanEffect);
+export const POLICY_STATE_OPTIONS = Object.values(CertPolicyState);
export enum CertSubjectAttributeInclude {
OPTIONAL = "optional",
@@ -273,7 +280,8 @@ export const POLICY_PRESET_IDS = {
DEVICE: "device",
USER: "user",
EMAIL_PROTECTION: "email-protection",
- DUAL_PURPOSE_SERVER: "dual-purpose-server"
+ DUAL_PURPOSE_SERVER: "dual-purpose-server",
+ INTERMEDIATE_CA: "intermediate-ca"
} as const;
export type PolicyPresetId = (typeof POLICY_PRESET_IDS)[keyof typeof POLICY_PRESET_IDS];
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/policy-presets.ts b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/policy-presets.ts
index e7ee5223aa..0fb2a3a6fe 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/policy-presets.ts
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/policy-presets.ts
@@ -3,6 +3,7 @@ import {
CertDurationUnit,
CertExtendedKeyUsageType,
CertKeyUsageType,
+ CertPolicyState,
CertSanInclude,
CertSubjectAlternativeNameType,
CertSubjectAttributeInclude,
@@ -381,5 +382,61 @@ export const CERTIFICATE_POLICY_PRESETS: CertificatePolicyPreset[] = [
allowedKeyTypes: [...ALGORITHM_FAMILIES.ECDSA.key]
}
}
+ },
+ {
+ id: POLICY_PRESET_IDS.INTERMEDIATE_CA,
+ name: "Intermediate CA Certificate",
+ description:
+ "Certificate for intermediate Certificate Authorities. Allows signing end-entity certificates and CRLs.",
+ useCase: "Intermediate CA, subordinate CA, issuing CA",
+ formData: {
+ name: "Intermediate CA Certificate",
+ description:
+ "Certificate for intermediate Certificate Authorities. Allows signing end-entity certificates and CRLs.",
+ basicConstraints: {
+ isCA: CertPolicyState.REQUIRED,
+ maxPathLength: 0
+ },
+ keyUsages: {
+ requiredUsages: [CertKeyUsageType.KEY_CERT_SIGN, CertKeyUsageType.CRL_SIGN],
+ optionalUsages: [
+ CertKeyUsageType.KEY_CERT_SIGN,
+ CertKeyUsageType.CRL_SIGN,
+ CertKeyUsageType.DIGITAL_SIGNATURE
+ ]
+ },
+ extendedKeyUsages: {
+ requiredUsages: [],
+ optionalUsages: [CertExtendedKeyUsageType.OCSP_SIGNING]
+ },
+ validity: {
+ maxDuration: {
+ value: 10,
+ unit: CertDurationUnit.YEARS
+ }
+ },
+ attributes: [
+ {
+ type: CertSubjectAttributeType.COMMON_NAME,
+ include: CertSubjectAttributeInclude.OPTIONAL,
+ value: ["*"]
+ },
+ {
+ type: CertSubjectAttributeType.ORGANIZATION,
+ include: CertSubjectAttributeInclude.OPTIONAL,
+ value: ["*"]
+ }
+ ],
+ subjectAlternativeNames: [],
+ signatureAlgorithm: {
+ allowedAlgorithms: [
+ ...ALGORITHM_FAMILIES.RSA.signature,
+ ...ALGORITHM_FAMILIES.ECDSA.signature
+ ]
+ },
+ keyAlgorithm: {
+ allowedKeyTypes: [...ALGORITHM_FAMILIES.RSA.key, ...ALGORITHM_FAMILIES.ECDSA.key]
+ }
+ }
}
];
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/schemas.ts b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/schemas.ts
index 25f3c1da5c..2fb7c4bb88 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/schemas.ts
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/schemas.ts
@@ -4,6 +4,7 @@ import {
CertDurationUnit,
CertExtendedKeyUsageType,
CertKeyUsageType,
+ CertPolicyState,
CertSanInclude,
CertSubjectAlternativeNameType,
CertSubjectAttributeInclude,
@@ -53,7 +54,7 @@ export const uiKeyAlgorithmSchema = z.object({
});
export const uiBasicConstraintsSchema = z.object({
- isCA: z.boolean().default(false),
+ isCA: z.nativeEnum(CertPolicyState).default(CertPolicyState.DENIED),
maxPathLength: z
.number()
.min(-1, "Path length must be -1 (unlimited) or greater")
@@ -70,7 +71,8 @@ export const uiPresetSchema = z
POLICY_PRESET_IDS.DEVICE,
POLICY_PRESET_IDS.USER,
POLICY_PRESET_IDS.EMAIL_PROTECTION,
- POLICY_PRESET_IDS.DUAL_PURPOSE_SERVER
+ POLICY_PRESET_IDS.DUAL_PURPOSE_SERVER,
+ POLICY_PRESET_IDS.INTERMEDIATE_CA
])
.default(POLICY_PRESET_IDS.CUSTOM);