Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
misc: more feedback
Sheen Capadnganfa420acba01b
diff --git a/backend/src/server/routes/v1/certificate-authority-routers/general-certificate-authority-router.ts b/backend/src/server/routes/v1/certificate-authority-routers/general-certificate-authority-router.tsindex 6c8dd59ed5..4e90f41b5b 100644--- a/backend/src/server/routes/v1/certificate-authority-routers/general-certificate-authority-router.ts+++ b/backend/src/server/routes/v1/certificate-authority-routers/general-certificate-authority-router.ts@@ -30,6 +30,37 @@ const CertificateAuthoritySchema = z.discriminatedUnion("type", []);export const registerGeneralCertificateAuthorityRouter = async (server: FastifyZodProvider) => {+ server.route({+ method: "GET",+ url: "/quota",+ config: {+ rateLimit: readLimit+ },+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),+ schema: {+ operationId: "getCertificateAuthorityQuotaV1",+ tags: [ApiDocsTags.PkiCertificateAuthorities],+ description: "Get certificate authority usage against the plan's limits",+ response: {+ 200: z.object({+ certificateAuthorities: z.object({+ used: z.number().int().describe("Certificate authorities of every type currently in use."),+ limit: z.number().int().nullable().describe("The plan's cap, or null when uncapped.")+ }),+ internalCertificateAuthorities: z.object({+ used: z.number().int().describe("Internal certificate authorities currently in use."),+ limit: z.number().int().nullable().describe("The plan's cap, or null when uncapped.")+ })+ })+ }+ },+ handler: async (req) =>+ server.services.certificateAuthority.getCertificateAuthorityQuota(+ { projectId: req.internalCertManagerProjectId },+ req.permission+ )+ });+server.route({method: "GET",url: "/",diff --git a/backend/src/server/routes/v1/certificate-router.ts b/backend/src/server/routes/v1/certificate-router.tsindex 39a51bd018..0257744d01 100644--- a/backend/src/server/routes/v1/certificate-router.ts+++ b/backend/src/server/routes/v1/certificate-router.ts@@ -2,7 +2,6 @@import RE2 from "re2";import { z } from "zod";-import { CertificatesSchema } from "@app/db/schemas";import { EventType } from "@app/ee/services/audit-log/audit-log-types";import { ApiDocsTags, CERTIFICATES } from "@app/lib/api-docs";import { ms } from "@app/lib/ms";@@ -13,6 +12,7 @@ import { openApiHidden } from "@app/server/lib/schemas";import { getTelemetryDistinctId } from "@app/server/lib/telemetry";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";+import { SanitizedCertificateSchema } from "@app/services/certificate/certificate-schemas";import { CertKeyAlgorithm, CertSignatureAlgorithm, CrlReason } from "@app/services/certificate/certificate-types";import { CaType } from "@app/services/certificate-authority/certificate-authority-enums";import { validateCaDateField } from "@app/services/certificate-authority/certificate-authority-validators";@@ -1349,7 +1349,7 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {}),response: {200: z.object({- certificate: CertificatesSchema.omit({ orderId: true }).extend({+ certificate: SanitizedCertificateSchema.extend({subject: z.object({commonName: z.string().optional(),@@ -1767,7 +1767,7 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {}),response: {200: z.object({- certificate: CertificatesSchema.omit({ orderId: true })+ certificate: SanitizedCertificateSchema})}},@@ -1828,7 +1828,7 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {}),response: {200: z.object({- certificate: CertificatesSchema.omit({ orderId: true })+ certificate: SanitizedCertificateSchema})}},diff --git a/backend/src/server/routes/v1/deprecated-certificate-router.ts b/backend/src/server/routes/v1/deprecated-certificate-router.tsindex 355c15771b..05559f67e4 100644--- a/backend/src/server/routes/v1/deprecated-certificate-router.ts+++ b/backend/src/server/routes/v1/deprecated-certificate-router.ts@@ -2,7 +2,6 @@import RE2 from "re2";import { z } from "zod";-import { CertificatesSchema } from "@app/db/schemas";import { EventType } from "@app/ee/services/audit-log/audit-log-types";import { ApiDocsTags, CERTIFICATE_AUTHORITIES, CERTIFICATES } from "@app/lib/api-docs";import { ms } from "@app/lib/ms";@@ -11,6 +10,7 @@ import { addNoCacheHeaders } from "@app/server/lib/caching";import { getTelemetryDistinctId } from "@app/server/lib/telemetry";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";+import { SanitizedCertificateSchema } from "@app/services/certificate/certificate-schemas";import { CertExtendedKeyUsage, CertKeyUsage, CrlReason } from "@app/services/certificate/certificate-types";import {validateAltNamesField,@@ -35,7 +35,7 @@ export const registerDeprecatedCertRouter = async (server: FastifyZodProvider) =}),response: {200: z.object({- certificate: CertificatesSchema.omit({ orderId: true })+ certificate: SanitizedCertificateSchema})}},@@ -534,7 +534,7 @@ export const registerDeprecatedCertRouter = async (server: FastifyZodProvider) =}),response: {200: z.object({- certificate: CertificatesSchema.omit({ orderId: true })+ certificate: SanitizedCertificateSchema})}},diff --git a/backend/src/server/routes/v1/pki-subscriber-router.ts b/backend/src/server/routes/v1/pki-subscriber-router.tsindex 1952fc3884..887844ea04 100644--- a/backend/src/server/routes/v1/pki-subscriber-router.ts+++ b/backend/src/server/routes/v1/pki-subscriber-router.ts@@ -1,7 +1,6 @@import RE2 from "re2";import { z } from "zod";-import { CertificatesSchema } from "@app/db/schemas";import { EventType } from "@app/ee/services/audit-log/audit-log-types";import { ApiDocsTags, PKI_SUBSCRIBERS } from "@app/lib/api-docs";import { ms } from "@app/lib/ms";@@ -11,6 +10,7 @@ import { slugSchema } from "@app/server/lib/schemas";import { getTelemetryDistinctId } from "@app/server/lib/telemetry";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";+import { SanitizedCertificateSchema } from "@app/services/certificate/certificate-schemas";import { CertExtendedKeyUsage, CertKeyUsage } from "@app/services/certificate/certificate-types";import { validateAltNameField } from "@app/services/certificate-authority/certificate-authority-validators";import { sanitizedPkiSubscriber } from "@app/services/pki-subscriber/pki-subscriber-schema";@@ -747,7 +747,7 @@ export const registerPkiSubscriberRouter = async (server: FastifyZodProvider) =>}),response: {200: z.object({- certificates: z.array(CertificatesSchema.omit({ orderId: true })),+ certificates: z.array(SanitizedCertificateSchema),totalCount: z.number()})}diff --git a/backend/src/server/routes/v1/project-router.ts b/backend/src/server/routes/v1/project-router.tsindex 77c89dbca5..ed690de27a 100644--- a/backend/src/server/routes/v1/project-router.ts+++ b/backend/src/server/routes/v1/project-router.ts@@ -2,7 +2,6 @@ import slugify from "@sindresorhus/slugify";import { z } from "zod";import {- CertificatesSchema,IntegrationsSchema,PkiAlertsSchema,PkiCollectionsSchema,@@ -26,6 +25,7 @@ import { slugSchema } from "@app/server/lib/schemas";import { getTelemetryDistinctId } from "@app/server/lib/telemetry";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { ActorType, AuthMode } from "@app/services/auth/auth-type";+import { SanitizedCertificateSchema } from "@app/services/certificate/certificate-schemas";import { CaStatus } from "@app/services/certificate-authority/certificate-authority-enums";import { sanitizedCertificateTemplate } from "@app/services/certificate-template/certificate-template-schema";import { validateMicrosoftTeamsChannelsSchema } from "@app/services/microsoft-teams/microsoft-teams-fns";@@ -1276,7 +1276,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {}),response: {200: z.object({- certificates: z.array(CertificatesSchema.omit({ orderId: true }).extend({ hasPrivateKey: z.boolean() })),+ certificates: z.array(SanitizedCertificateSchema.extend({ hasPrivateKey: z.boolean() })),totalCount: z.number()})}@@ -1367,7 +1367,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {response: {200: z.object({certificates: z.array(- CertificatesSchema.omit({ orderId: true }).extend({+ SanitizedCertificateSchema.extend({hasPrivateKey: z.boolean(),caName: z.string().nullable().optional(),profileName: z.string().nullable().optional(),diff --git a/backend/src/server/routes/v2/deprecated-project-router.ts b/backend/src/server/routes/v2/deprecated-project-router.tsindex 44d74825da..26474900e6 100644--- a/backend/src/server/routes/v2/deprecated-project-router.ts+++ b/backend/src/server/routes/v2/deprecated-project-router.ts@@ -1,12 +1,6 @@import { z } from "zod";-import {- CertificatesSchema,- PkiAlertsSchema,- PkiCollectionsSchema,- ProjectKeysSchema,- ProjectType-} from "@app/db/schemas";+import { PkiAlertsSchema, PkiCollectionsSchema, ProjectKeysSchema, ProjectType } from "@app/db/schemas";import { EventType } from "@app/ee/services/audit-log/audit-log-types";import { InfisicalProjectTemplate } from "@app/ee/services/project-template/project-template-types";import { ApiDocsTags, PROJECTS } from "@app/lib/api-docs";@@ -15,6 +9,7 @@ import { slugSchema } from "@app/server/lib/schemas";import { getTelemetryDistinctId } from "@app/server/lib/telemetry";import { verifyAuth } from "@app/server/plugins/auth/verify-auth";import { AuthMode } from "@app/services/auth/auth-type";+import { SanitizedCertificateSchema } from "@app/services/certificate/certificate-schemas";import { CaStatus } from "@app/services/certificate-authority/certificate-authority-enums";import { sanitizedCertificateTemplate } from "@app/services/certificate-template/certificate-template-schema";import { sanitizedPkiSubscriber } from "@app/services/pki-subscriber/pki-subscriber-schema";@@ -392,7 +387,7 @@ export const registerDeprecatedProjectRouter = async (server: FastifyZodProvider}),response: {200: z.object({- certificates: z.array(CertificatesSchema.omit({ orderId: true })),+ certificates: z.array(SanitizedCertificateSchema),totalCount: z.number()})}diff --git a/backend/src/services/certificate-authority/certificate-authority-quota-fns.ts b/backend/src/services/certificate-authority/certificate-authority-quota-fns.tsindex 4f4151f197..d19fb67143 100644--- a/backend/src/services/certificate-authority/certificate-authority-quota-fns.ts+++ b/backend/src/services/certificate-authority/certificate-authority-quota-fns.ts@@ -1,4 +1,5 @@import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";+import { TFeatureSet } from "@app/ee/services/license/license-types";import { BadRequestError, NotFoundError } from "@app/lib/errors";import { TProjectDALFactory } from "@app/services/project/project-dal";@@ -10,6 +11,16 @@ export type TCertificateAuthorityQuotaDeps = {certificateAuthorityDAL: Pick<TCertificateAuthorityDALFactory, "countCasByOrgId" | "countInternalCasByOrgId">;};+// A contract granting more internal CAs than total CAs is a License Server misconfiguration; honour+// the larger grant. Guarded on both being numbers because the free tier leaves maxInternalCas null+// while capping maxCas at 1, so treating null as unlimited would lift that cap.+//+// Exported so the quota endpoint reports the same ceiling this module enforces.+export const resolveEffectiveMaxCas = (plan: Pick<TFeatureSet, "maxCas" | "maxInternalCas">) =>+ typeof plan.maxCas === "number" && typeof plan.maxInternalCas === "number"+ ? Math.max(plan.maxCas, plan.maxInternalCas)+ : plan.maxCas;+// Enforced where the CA row is written rather than in createCertificateAuthority alone: the still-live// POST /cert-manager/ca route calls internalCertificateAuthorityService.createCa directly, so a check// that only sat in the former was bypassable.@@ -29,14 +40,7 @@ export const assertCertificateAuthorityQuota = async ({if (!project) throw new NotFoundError({ message: `Project with ID '${projectId}' not found` });const plan = await deps.licenseService.getPlan(project.orgId);-- // A contract granting more internal CAs than total CAs is a License Server misconfiguration; honour- // the larger grant. Guarded on both being numbers because the free tier leaves maxInternalCas null- // while capping maxCas at 1, so treating null as unlimited would lift that cap.- const maxCas =- typeof plan.maxCas === "number" && typeof plan.maxInternalCas === "number"- ? Math.max(plan.maxCas, plan.maxInternalCas)- : plan.maxCas;+ const maxCas = resolveEffectiveMaxCas(plan);if (typeof maxCas === "number") {const used = await deps.certificateAuthorityDAL.countCasByOrgId(project.orgId);diff --git a/backend/src/services/certificate-authority/certificate-authority-service.ts b/backend/src/services/certificate-authority/certificate-authority-service.tsindex e660d124fe..3fd9a2ea7c 100644--- a/backend/src/services/certificate-authority/certificate-authority-service.ts+++ b/backend/src/services/certificate-authority/certificate-authority-service.ts@@ -81,7 +81,7 @@ import {import { TCertificateAuthorityDALFactory } from "./certificate-authority-dal";import { CaType } from "./certificate-authority-enums";import { CERTIFICATE_AUTHORITIES_TYPE_MAP } from "./certificate-authority-maps";-import { assertCertificateAuthorityQuota } from "./certificate-authority-quota-fns";+import { assertCertificateAuthorityQuota, resolveEffectiveMaxCas } from "./certificate-authority-quota-fns";import { TCertificateAuthoritySecretDALFactory } from "./certificate-authority-secret-dal";import {TCertificateAuthority,@@ -641,6 +641,36 @@ export const certificateAuthorityServiceFactory = ({throw new BadRequestError({ message: "Invalid certificate authority type" });};+ const getCertificateAuthorityQuota = async ({ projectId }: { projectId: string }, actor: OrgServiceActor) => {+ const { permission } = await permissionService.getProjectPermission({+ actor: actor.type,+ actorId: actor.id,+ projectId,+ actorAuthMethod: actor.authMethod,+ actorOrgId: actor.orgId,+ actionProjectType: ActionProjectType.CertificateManager+ });++ ForbiddenError.from(permission).throwUnlessCan(+ ProjectPermissionCertificateAuthorityActions.Read,+ ProjectPermissionSub.CertificateAuthorities+ );++ const project = await projectDAL.findById(projectId);+ if (!project) throw new NotFoundError({ message: `Project with ID '${projectId}' not found` });++ const plan = await licenseService.getPlan(project.orgId);+ const [totalUsed, internalUsed] = await Promise.all([+ certificateAuthorityDAL.countCasByOrgId(project.orgId),+ certificateAuthorityDAL.countInternalCasByOrgId(project.orgId)+ ]);++ return {+ certificateAuthorities: { used: totalUsed, limit: resolveEffectiveMaxCas(plan) },+ internalCertificateAuthorities: { used: internalUsed, limit: plan.maxInternalCas ?? null }+ };+ };+const listCertificateAuthoritiesByProjectId = async ({ projectId, type }: { projectId: string; type: CaType },actor: OrgServiceActor@@ -1460,6 +1490,7 @@ export const certificateAuthorityServiceFactory = ({createCertificateAuthority,findCertificateAuthorityById,listCertificateAuthoritiesByProjectId,+ getCertificateAuthorityQuota,findCertificateAuthorityByNameAndProjectId,updateCertificateAuthority,deleteCertificateAuthority,diff --git a/backend/src/services/certificate/certificate-schemas.ts b/backend/src/services/certificate/certificate-schemas.tsnew file mode 100644index 0000000000..578d0c5d76--- /dev/null+++ b/backend/src/services/certificate/certificate-schemas.ts@@ -0,0 +1,10 @@+import { CertificatesSchema } from "@app/db/schemas";++// The certificates table carries bookkeeping columns the API does not expose: orderId groups a+// renewal chain, and quotaKey / hasWildcard exist so the licence quota can be counted from an index.+// Responses build on this rather than omitting them per route, so a new endpoint cannot leak them.+export const SanitizedCertificateSchema = CertificatesSchema.omit({+ orderId: true,+ quotaKey: true,+ hasWildcard: true+});diff --git a/frontend/src/hooks/api/ca/index.tsx b/frontend/src/hooks/api/ca/index.tsxindex 61cc1825fb..fe33bd655c 100644--- a/frontend/src/hooks/api/ca/index.tsx+++ b/frontend/src/hooks/api/ca/index.tsx@@ -39,6 +39,7 @@ export {useGetCaCertTemplates,useGetCaCrls,useGetCaCsr,+ useGetCaQuota,useGetCaSigningConfig,useGetInternalCaById,useListCasByProjectId,@@ -46,6 +47,7 @@ export {useListExternalCasByProjectId} from "./queries";export type {+ TCaQuota,TInternalCertificateAuthority,TOrderCertificateDTO,TOrderCertificateResponsediff --git a/frontend/src/hooks/api/ca/queries.tsx b/frontend/src/hooks/api/ca/queries.tsxindex 834c2178c8..bcb5d1d9a6 100644--- a/frontend/src/hooks/api/ca/queries.tsx+++ b/frontend/src/hooks/api/ca/queries.tsx@@ -7,6 +7,7 @@ import { CaRenewalStatus, CaSigningConfigType, CaType } from "./enums";import {TAdcsTemplate,TAzureAdCsTemplate,+ TCaQuota,TInternalCertificateAuthority,TUnifiedCertificateAuthority} from "./types";@@ -27,7 +28,8 @@ export const caKeys = {getAzureAdcsTemplates: (caId: string) => [{ caId }, "azure-adcs-templates"],getAdcsTemplates: (caId: string) => [{ caId }, "adcs-templates"],getCaSigningConfig: (caId: string) => [{ caId }, "ca-signing-config"],- getCaAutoRenewal: (caId: string) => [{ caId }, "ca-auto-renewal"]+ getCaAutoRenewal: (caId: string) => [{ caId }, "ca-auto-renewal"],+ getCaQuota: () => ["ca-quota"] as const};export const useGetCa = ({@@ -321,3 +323,13 @@ export const useGetAdcsTemplates = ({ caId, isAdcsCa }: { caId: string; isAdcsCaenabled: Boolean(caId && isAdcsCa)});};++export const useGetCaQuota = (options?: { enabled?: boolean }) =>+ useQuery({+ queryKey: caKeys.getCaQuota(),+ queryFn: async () => {+ const { data } = await apiRequest.get<TCaQuota>("/api/v1/cert-manager/ca/quota");+ return data;+ },+ enabled: options?.enabled ?? true+ });diff --git a/frontend/src/hooks/api/ca/types.ts b/frontend/src/hooks/api/ca/types.tsindex 6451c72ee4..6c2af91dcb 100644--- a/frontend/src/hooks/api/ca/types.ts+++ b/frontend/src/hooks/api/ca/types.ts@@ -382,3 +382,8 @@ export type TRenewCaResponse = {serialNumber: string;projectId: string;};++export type TCaQuota = {+ certificateAuthorities: { used: number; limit: number | null };+ internalCertificateAuthorities: { used: number; limit: number | null };+};diff --git a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDistributionPointsSection.tsx b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDistributionPointsSection.tsxindex 4d17b764aa..4e3ef18378 100644--- a/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDistributionPointsSection.tsx+++ b/frontend/src/pages/cert-manager/CertAuthDetailsByIDPage/components/CaDistributionPointsSection.tsx@@ -6,6 +6,7 @@ import { zodResolver } from "@hookform/resolvers/zod";import { PencilIcon } from "lucide-react";import { z } from "zod";+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";import { createNotification } from "@app/components/notifications";import { ProjectPermissionCan } from "@app/components/permissions";import {@@ -32,7 +33,11 @@ import {DetailValue,IconButton} from "@app/components/v3";-import { ProjectPermissionCertificateAuthorityActions, ProjectPermissionSub } from "@app/context";+import {+ ProjectPermissionCertificateAuthorityActions,+ ProjectPermissionSub,+ useSubscription+} from "@app/context";import {CaType,MAX_DISTRIBUTION_POINT_URL_LENGTH,@@ -83,7 +88,11 @@ const editSchema = z.object({type EditFormData = z.infer<typeof editSchema>;export const CaDistributionPointsSection = ({ caId }: Props) => {- const { popUp, handlePopUpToggle } = usePopUp(["editCrlDistributionPoints"] as const);+ const { popUp, handlePopUpToggle } = usePopUp([+ "editCrlDistributionPoints",+ "upgradePlan"+ ] as const);+ const { subscription } = useSubscription();const { data } = useGetCa({ caId, type: CaType.INTERNAL });const ca = data as TInternalCertificateAuthority | undefined;@@ -108,6 +117,16 @@ export const CaDistributionPointsSection = ({ caId }: Props) => {const crlUrls = useFieldArray({ control, name: "crlDistributionPointUrls" });+ // Only adding a custom URL is plan-gated; toggling the managed URL and removing existing ones+ // stay available, so the restriction belongs on this action rather than on opening the modal.+ const handleAddCrlUrl = () => {+ if (!subscription.caCrl) {+ handlePopUpToggle("upgradePlan", true);+ return;+ }+ crlUrls.append({ value: "" });+ };+if (!ca) return null;const mirrorUrls = ca.configuration.crlDistributionPointUrls ?? [];@@ -259,7 +278,7 @@ export const CaDistributionPointsSection = ({ caId }: Props) => {size="xs"variant="outline_bg"isDisabled={crlUrls.fields.length >= MAX_INTERNAL_CA_DISTRIBUTION_POINT_URLS}- onClick={() => crlUrls.append({ value: "" })}+ onClick={handleAddCrlUrl}>Add URL</ButtonV2>@@ -283,6 +302,12 @@ export const CaDistributionPointsSection = ({ caId }: Props) => {</form></ModalContent></Modal>++ <UpgradePlanModal+ isOpen={popUp.upgradePlan.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}+ text="Certificate revocation lists are available on Infisical's Enterprise plan."+ /></>);};diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsxindex 08d673abc9..9a852cdd92 100644--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx@@ -1,6 +1,7 @@import { useState } from "react";import { PlusIcon } from "lucide-react";+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";import { createNotification } from "@app/components/notifications";import { ProjectPermissionCan } from "@app/components/permissions";import { DeleteActionModal } from "@app/components/v2";@@ -19,7 +20,14 @@ import {ProjectPermissionSub,useProject} from "@app/context";-import { CaStatus, CaType, useDeleteCa, useGetCa, useUpdateCa } from "@app/hooks/api";+import {+ CaStatus,+ CaType,+ useDeleteCa,+ useGetCa,+ useGetCaQuota,+ useUpdateCa+} from "@app/hooks/api";import { TInternalCertificateAuthority } from "@app/hooks/api/ca/types";import { CertKeySource } from "@app/hooks/api/signers";import { usePopUp } from "@app/hooks/usePopUp";@@ -40,9 +48,30 @@ export const CaSection = () => {"caCert","installCaCert","deleteCa",- "caStatus" // enable / disable+ "caStatus", // enable / disable+ "upgradePlan"] as const);+ const { data: caQuota } = useGetCaQuota();+ // An internal CA counts against both caps, so whichever runs out first blocks it. The message names+ // that one, since "1 of 1 internal CAs" and "1 of 1 CAs" call for different upgrades.+ const exhausted = [+ { noun: "certificate authorities", ...caQuota?.certificateAuthorities },+ { noun: "internal certificate authorities", ...caQuota?.internalCertificateAuthorities }+ ].find((entry) => typeof entry.limit === "number" && (entry.used ?? 0) >= entry.limit);++ const handleCreateCa = () => {+ if (exhausted) {+ // The allowance is shared across the organization and any sub-organizations, while this table+ // shows one project, so the count is named rather than left to look like a mismatch.+ handlePopUpOpen("upgradePlan", {+ text: `Your plan includes ${exhausted.limit} ${exhausted.noun} and all ${exhausted.used} are in use across your organization. Upgrade to add more.`+ });+ return;+ }+ setIsCreateWizardOpen(true);+ };+const deleteCaId = (popUp?.deleteCa?.data as { caId?: string })?.caId;const { data: caPendingDeleteData } = useGetCa({caId: deleteCaId ?? "",@@ -98,11 +127,7 @@ export const CaSection = () => {a={ProjectPermissionSub.CertificateAuthorities}>{(isAllowed) => (- <Button- variant="project"- onClick={() => setIsCreateWizardOpen(true)}- isDisabled={!isAllowed}- >+ <Button variant="project" onClick={handleCreateCa} isDisabled={!isAllowed}><PlusIcon />Create Internal CA</Button>@@ -114,6 +139,11 @@ export const CaSection = () => {<CaTable handlePopUpOpen={handlePopUpOpen} /></CardContent><CreateCaWizard isOpen={isCreateWizardOpen} onOpenChange={setIsCreateWizardOpen} />+ <UpgradePlanModal+ isOpen={popUp.upgradePlan.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}+ text={(popUp.upgradePlan?.data as { text: string })?.text}+ /><CaInstallCertModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} /><CaCertModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} /><DeleteActionModaldiff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/DistributionStep.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/DistributionStep.tsxindex df5eb6cf09..01f396339f 100644--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/DistributionStep.tsx+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CreateCaWizard/DistributionStep.tsx@@ -13,6 +13,7 @@ import {Input,Switch} from "@app/components/v3";+import { useSubscription } from "@app/context";import { MAX_INTERNAL_CA_DISTRIBUTION_POINT_URLS } from "@app/hooks/api/ca";import { CaWizardForm } from "./schemas";@@ -23,6 +24,10 @@ type Props = {export const DistributionStep = ({ form }: Props) => {const crlUrls = useFieldArray({ control: form.control, name: "crlDistributionPointUrls" });+ const { subscription } = useSubscription();+ // Creating a CA with any custom URL is refused by the plan gate, so the control is disabled+ // up front rather than failing at the end of the wizard.+ const canAddCrlUrls = subscription.caCrl;return (<FieldGroup>@@ -77,7 +82,9 @@ export const DistributionStep = ({ form }: Props) => {variant="outline"size="sm"className="self-start"- isDisabled={crlUrls.fields.length >= MAX_INTERNAL_CA_DISTRIBUTION_POINT_URLS}+ isDisabled={+ !canAddCrlUrls || crlUrls.fields.length >= MAX_INTERNAL_CA_DISTRIBUTION_POINT_URLS+ }onClick={() => crlUrls.append({ value: "" })}><PlusIcon className="h-4 w-4" />@@ -85,8 +92,9 @@ export const DistributionStep = ({ form }: Props) => {</Button></div><FieldDescription>- Backup CRL URLs embedded in issued certificates. Up to{" "}- {MAX_INTERNAL_CA_DISTRIBUTION_POINT_URLS}.+ {canAddCrlUrls+ ? `Backup CRL URLs embedded in issued certificates. Up to ${MAX_INTERNAL_CA_DISTRIBUTION_POINT_URLS}.`+ : "Custom CRL distribution points are available on Infisical's Enterprise plan."}</FieldDescription></FieldContent></Field>diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsxindex e987d511c7..b756a7a99b 100644--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx@@ -1,5 +1,6 @@import { PlusIcon } from "lucide-react";+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";import { createNotification } from "@app/components/notifications";import { ProjectPermissionCan } from "@app/components/permissions";import { DeleteActionModal } from "@app/components/v2";@@ -18,7 +19,7 @@ import {ProjectPermissionSub,useProject} from "@app/context";-import { CaStatus, CaType, useDeleteCa, useUpdateCa } from "@app/hooks/api";+import { CaStatus, CaType, useDeleteCa, useGetCaQuota, useUpdateCa } from "@app/hooks/api";import { usePopUp } from "@app/hooks/usePopUp";import { PkiDocsUrls } from "../../pki-docs-urls";@@ -33,9 +34,26 @@ export const ExternalCaSection = () => {const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp(["ca","deleteCa",- "caStatus" // enable / disable+ "caStatus", // enable / disable+ "upgradePlan"] as const);+ // maxCas covers every CA type, so an external CA is capped the same way an internal one is.+ // maxInternalCas is deliberately not consulted here: it caps INTERNAL only.+ const { data: caQuota } = useGetCaQuota();+ const caLimit = caQuota?.certificateAuthorities;+ const isAtCaLimit = typeof caLimit?.limit === "number" && caLimit.used >= caLimit.limit;++ const handleCreateCa = () => {+ if (isAtCaLimit) {+ handlePopUpOpen("upgradePlan", {+ text: `Your plan includes ${caLimit.limit} certificate authorities and all ${caLimit.used} are in use across your organization. Upgrade to add more.`+ });+ return;+ }+ handlePopUpOpen("ca");+ };+const onRemoveCaSubmit = async (id: string, type: CaType) => {if (!currentProject?.id) return;@@ -87,11 +105,7 @@ export const ExternalCaSection = () => {a={ProjectPermissionSub.CertificateAuthorities}>{(isAllowed) => (- <Button- variant="project"- onClick={() => handlePopUpOpen("ca")}- isDisabled={!isAllowed}- >+ <Button variant="project" onClick={handleCreateCa} isDisabled={!isAllowed}><PlusIcon />Create External CA</Button>@@ -139,6 +153,12 @@ export const ExternalCaSection = () => {)}/>++ <UpgradePlanModal+ isOpen={popUp.upgradePlan.isOpen}+ onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}+ text={(popUp.upgradePlan?.data as { text: string })?.text}+ /></Card>);};diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAltNamesField.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAltNamesField.tsxindex 817870622d..9a1cbd1e98 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAltNamesField.tsx+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAltNamesField.tsx@@ -14,6 +14,7 @@ import {SelectTrigger,SelectValue} from "@app/components/v3";+import { useSubscription } from "@app/context";import { CertSubjectAlternativeNameType } from "@app/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants";import { PolicyNotice, PolicyRowGuidance } from "./certificatePolicyGuidance";@@ -48,6 +49,11 @@ export const SubjectAltNamesField = ({namePrefix = "subjectAltNames"}: SubjectAltNamesFieldProps) => {const sanTypeLabels = getSanTypeLabels();+ const { subscription } = useSubscription();+ const { maxSansPerCertificate, maxWildcardCertificates } = subscription;+ // 0 means the plan has no wildcard support at all, which the backend refuses before it counts+ // anything, so it is the one cap this form can mirror exactly.+ const areWildcardsUnavailable = maxWildcardCertificates === 0;return (<Controller@@ -56,14 +62,22 @@ export const SubjectAltNamesField = ({shouldUnregister={shouldUnregister}render={({ field: { onChange, value } }) => {const currentValues: SubjectAltName[] = value || [];+ const isAtSanLimit =+ typeof maxSansPerCertificate === "number" &&+ currentValues.length >= maxSansPerCertificate;return (<Field className="mb-4"><FieldLabel>Subject Alternative Names (SANs)</FieldLabel><div className="space-y-3">{currentValues.map((san, index) => {const policy = policyRows?.[index];+ const isBlockedWildcard = areWildcardsUnavailable && san.value?.includes("*");const rowError =- rowErrors?.[index] ?? (revealPolicyErrors ? policy?.error : undefined);+ rowErrors?.[index] ??+ (isBlockedWildcard+ ? "Wildcard certificates are not available on your plan."+ : undefined) ??+ (revealPolicyErrors ? policy?.error : undefined);return (// eslint-disable-next-line react/no-array-index-key@@ -124,6 +138,7 @@ export const SubjectAltNamesField = ({type="button"variant="outline"size="sm"+ isDisabled={isAtSanLimit}onClick={() => {const defaultType =allowedSanTypes.length > 0@@ -135,6 +150,13 @@ export const SubjectAltNamesField = ({<Plus className="size-4" /> Add SAN</Button></div>+ {isAtSanLimit && (+ <PolicyRowMessage+ lines={[+ `Your plan allows up to ${maxSansPerCertificate} subject alternative names per certificate.`+ ]}+ />+ )}<FieldError>{error}</FieldError>{revealPolicyErrors && <PolicyNoticeList notices={policyNotices ?? []} />}</Field>