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
No need for allowEmptyCommonName flag, just allow empty CN for all
Fang-Pen Lin810c06c6d7dd
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.tsindex 2a4aa173b5..5e42dc3831 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@@ -1577,8 +1577,7 @@ export const internalCertificateAuthorityServiceFactory = ({keyUsages,extendedKeyUsages,signatureAlgorithm,- keyAlgorithm,- allowEmptyCommonName+ keyAlgorithm} = dto;let collectionId = pkiCollectionId;@@ -1717,20 +1716,7 @@ export const internalCertificateAuthorityServiceFactory = ({const csrObj = new x509.Pkcs10CertificateRequest(csr);const dn = parseDistinguishedName(csrObj.subject);- let cn = commonName || dn.commonName;-- if (!cn) {- if (allowEmptyCommonName ?? false) {- // Notice: for modern TLS certificates, the CN is deprecated, many ACME clients will generate CSRs with without a CN- // we allow empty CN here to support ACME clients mostly. Since it's unclear what's the side effect of- // allowing empty CN for legacy PKI code, let's only do it if a true allowEmptyCommonName value is provided.- cn = "";- } else {- throw new BadRequestError({- message: "A common name (CN) is required in the CSR or as a parameter to this endpoint"- });- }- }+ const cn = (commonName || dn.commonName) ?? "";const { caPrivateKey, caSecret } = await getCaCredentials({caId: ca.id,@@ -1948,7 +1934,7 @@ export const internalCertificateAuthorityServiceFactory = ({certificateTemplateId: certificateTemplate?.id,status: CertStatus.ACTIVE,friendlyName: friendlyName || csrObj.subject,- commonName: cn!,+ commonName: cn,altNames: altNamesFromCsr || altNames,serialNumber,notBefore: notBeforeDate,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.tsindex 8d669f1d28..b4b037933b 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@@ -164,7 +164,6 @@ export type TSignCertFromCaDTO =keyAlgorithm?: string;isFromProfile?: boolean;profileId?: string;- allowEmptyCommonName?: boolean;}| ({isInternal: false;@@ -184,7 +183,6 @@ export type TSignCertFromCaDTO =keyAlgorithm?: string;isFromProfile?: boolean;profileId?: string;- allowEmptyCommonName?: boolean;} & Omit<TProjectPermission, "projectId">);export type TGetCaCertificateTemplatesDTO = {diff --git a/backend/src/services/certificate-v3/certificate-v3-service.ts b/backend/src/services/certificate-v3/certificate-v3-service.tsindex 1549c63a5c..a537ddc06b 100644--- a/backend/src/services/certificate-v3/certificate-v3-service.ts+++ b/backend/src/services/certificate-v3/certificate-v3-service.ts@@ -511,8 +511,7 @@ export const certificateV3ServiceFactory = ({actorAuthMethod,actorOrgId,enrollmentType,- removeRootsFromChain,- allowEmptyCommonName+ removeRootsFromChain}: TSignCertificateFromProfileDTO): Promise<Omit<TCertificateFromProfileResponse, "privateKey">> => {const profile = await validateProfileAndPermissions(profileId,@@ -583,8 +582,7 @@ export const certificateV3ServiceFactory = ({notAfter: normalizeDateForApi(notAfter),signatureAlgorithm: effectiveSignatureAlgorithm,keyAlgorithm: effectiveKeyAlgorithm,- isFromProfile: true,- allowEmptyCommonName+ isFromProfile: true});const cert = await certificateDAL.findOne({ serialNumber, caId: ca.id });diff --git a/backend/src/services/certificate-v3/certificate-v3-types.ts b/backend/src/services/certificate-v3/certificate-v3-types.tsindex 4f47e90996..ab638c5ed8 100644--- a/backend/src/services/certificate-v3/certificate-v3-types.ts+++ b/backend/src/services/certificate-v3/certificate-v3-types.ts@@ -39,7 +39,6 @@ export type TSignCertificateFromProfileDTO = {notAfter?: Date;enrollmentType: EnrollmentType;removeRootsFromChain?: boolean;- allowEmptyCommonName?: boolean;} & Omit<TProjectPermission, "projectId">;export type TOrderCertificateFromProfileDTO = {