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
Minor UI improvements on PKI basicConstraints
Carlos Monastyrskid3c91aa98e9a
diff --git a/backend/src/server/routes/v1/certificate-router.ts b/backend/src/server/routes/v1/certificate-router.tsindex 9ba52f7760..ca43ceed35 100644--- a/backend/src/server/routes/v1/certificate-router.ts+++ b/backend/src/server/routes/v1/certificate-router.ts@@ -149,7 +149,7 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {basicConstraints: z.object({isCA: z.boolean(),- pathLength: z.number().int().min(-1).optional()+ pathLength: z.number().int().min(0).optional()}).optional()})diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsxindex 201a5b96a8..ac2b05cc69 100644--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx@@ -73,7 +73,7 @@ const createSchema = (shouldShowSubjectSection: boolean) => {basicConstraints: z.object({isCA: z.boolean().default(false),- pathLength: z.number().min(-1).nullable().optional()+ pathLength: z.number().min(0).nullable().optional()}).optional(),ttl: z.string().trim().min(1, "TTL is required"),@@ -601,71 +601,73 @@ export const CertificateIssuanceModal = ({ popUp, handlePopUpToggle, profileId }<Controllercontrol={control}name="basicConstraints.pathLength"- render={({ field, fieldState: { error } }) => (- <FormControl- label={- <div className="flex items-center gap-1">- <span className="mb-1">Path Length</span>- <Tooltip- content={- <div className="max-w-xs">- <p className="font-medium">Values:</p>- <ul className="mt-1 list-disc pl-4 text-xs">- <li>- <strong>-1</strong> = Unlimited depth- </li>- <li>- <strong>0</strong> = Can only sign end-entity certs- </li>- <li>- <strong>1+</strong> = CA levels allowed beneath- </li>- </ul>- </div>- }- >- <FontAwesomeIcon- icon={faQuestionCircle}- size="sm"- className="ml-1 text-mineshaft-400"+ render={({ field, fieldState: { error } }) => {+ const isPathLengthRequired =+ constraints.templateRequiresCA &&+ typeof constraints.maxPathLength === "number" &&+ constraints.maxPathLength !== -1;+ return (+ <FormControl+ label={+ <div>+ <FormLabel+ isRequired={isPathLengthRequired}+ label="Path Length"+ icon={+ <Tooltip+ content={+ <div className="max-w-xs">+ <p className="font-medium">Values:</p>+ <ul className="mt-1 list-disc pl-4 text-xs">+ <li>+ <strong>Empty</strong> = Unlimited depth+ </li>+ <li>+ <strong>0</strong> = Can only sign end-entity+ certs+ </li>+ <li>+ <strong>1+</strong> = CA levels allowed+ beneath+ </li>+ </ul>+ </div>+ }+ >+ <FontAwesomeIcon icon={faQuestionCircle} size="sm" />+ </Tooltip>+ }/>- </Tooltip>- </div>- }- isError={Boolean(error)}- errorText={error?.message}- helperText={- constraints.maxPathLength !== undefined &&- constraints.maxPathLength !== null &&- constraints.maxPathLength !== -1- ? `Required. Policy maximum: ${constraints.maxPathLength}`- : "Sets the pathLen for this CA certificate. Controls how many levels of sub-CAs can exist below."- }- >- <Input- {...field}- type="number"- placeholder={- constraints.maxPathLength !== undefined &&- constraints.maxPathLength !== null &&- constraints.maxPathLength !== -1- ? "Enter path length (required)"- : "Leave empty for no constraint"+ </div>}- className="w-full"- value={field.value ?? ""}- onChange={(e) => {- const val = e.target.value;- if (val === "") {- field.onChange(undefined);- } else {- const numVal = parseInt(val, 10);- field.onChange(Number.isNaN(numVal) ? undefined : numVal);+ isError={Boolean(error)}+ errorText={error?.message}+ helperText="Sets the pathLen for this CA certificate. Controls how many levels of sub-CAs can exist below."+ >+ <Input+ {...field}+ type="number"+ min={0}+ placeholder={+ isPathLengthRequired+ ? "Enter path length (required)"+ : "Leave empty for no constraint"}- }}- />- </FormControl>- )}+ className="w-full"+ value={field.value ?? ""}+ onChange={(e) => {+ const val = e.target.value;+ if (val === "") {+ field.onChange(undefined);+ } else {+ const numVal = parseInt(val, 10);+ field.onChange(Number.isNaN(numVal) ? undefined : numVal);+ }+ }}+ />+ </FormControl>+ );+ }}/>)}</div>diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsxindex f3f0f6f01b..531664d3dd 100644--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsx+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/CreatePolicyModal.tsx@@ -1163,21 +1163,21 @@ export const CreatePolicyModal = ({ isOpen, onClose, policy, mode = "create" }:}isError={Boolean(error)}errorText={error?.message}- helperText="Defines the pathLen constraint applied to issued certificates."+ helperText="Defines the pathLen constraint applied to issued certificates. Path length limits how many intermediate CA certificates can exist downstream from this certificate in the certificate chain, helping to control the depth and complexity of your PKI hierarchy."><Input{...field}type="number"placeholder="Leave empty to omit the constraint"className="w-full"+ min={-1}value={field.value ?? ""}onChange={(e) => {- const val = e.target.value;- if (val === "") {- field.onChange(undefined);+ const { value } = e.target;+ if (!value || value === "" || !Number.isInteger(Number(value))) {+ field.onChange(value);} else {- const numVal = parseInt(val, 10);- field.onChange(Number.isNaN(numVal) ? undefined : numVal);+ field.onChange(Number(value));}}}/>