Skip to content

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

Address PR comments

Carlos Monastyrskid48b283923e1
diff --git a/backend/src/db/migrations/20260325201236_add-scep-enrollment.ts b/backend/src/db/migrations/20260325201236_add-scep-enrollment.ts
index 2a8f324756..b8d87a775d 100644
--- a/backend/src/db/migrations/20260325201236_add-scep-enrollment.ts
+++ b/backend/src/db/migrations/20260325201236_add-scep-enrollment.ts
@@ -36,6 +36,7 @@ export async function up(knex: Knex): Promise<void> {
t.binary("signerCertDer").notNullable();
t.uuid("certificateRequestId").nullable();
+ t.foreign("certificateRequestId").references("id").inTable(TableName.CertificateRequests).onDelete("SET NULL");
t.index("certificateRequestId");
t.string("clientCipherOid", 64).nullable();
diff --git a/backend/src/ee/services/license/license-fns.ts b/backend/src/ee/services/license/license-fns.ts
index f3b8e7ea33..b75ef22b5e 100644
--- a/backend/src/ee/services/license/license-fns.ts
+++ b/backend/src/ee/services/license/license-fns.ts
@@ -100,7 +100,7 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({
},
pkiEst: false,
pkiAcme: false,
- pkiScep: true,
+ pkiScep: false,
enforceMfa: false,
projectTemplates: false,
kmip: false,
diff --git a/backend/src/ee/services/license/license-types.ts b/backend/src/ee/services/license/license-types.ts
index 940da9b683..050ef6ebb5 100644
--- a/backend/src/ee/services/license/license-types.ts
+++ b/backend/src/ee/services/license/license-types.ts
@@ -79,7 +79,7 @@ export type TFeatureSet = {
};
pkiEst: boolean;
pkiAcme: false;
- pkiScep: boolean;
+ pkiScep: false;
enforceMfa: boolean;
projectTemplates: false;
kmip: false;
diff --git a/backend/src/ee/services/pki-scep/pki-scep-crypto.ts b/backend/src/ee/services/pki-scep/pki-scep-crypto.ts
index 5f3f799254..babd12847a 100644
--- a/backend/src/ee/services/pki-scep/pki-scep-crypto.ts
+++ b/backend/src/ee/services/pki-scep/pki-scep-crypto.ts
@@ -1,23 +1,12 @@
-import nodeCrypto from "node:crypto";
-
-import forge from "node-forge";
-
+import { crypto } from "@app/lib/crypto/cryptography";
+import { rsaVerify as rsaVerifyGeneric } from "@app/lib/crypto/rsa";
import { BadRequestError } from "@app/lib/errors";
-import { CIPHER_OID_MAP } from "./pki-scep-types";
-
-// Node.js native crypto removed RSA_PKCS1_PADDING for privateDecrypt (CVE-2023-46809).
-// SCEP mandates PKCS#1 v1.5 key transport per RFC 8894, so we use node-forge.
-export const rsaPkcs1Decrypt = (encryptedKey: Buffer, privateKeyDer: Buffer): Buffer => {
- const privateKeyPem = nodeCrypto
- .createPrivateKey({ key: privateKeyDer, format: "der", type: "pkcs8" })
- .export({ type: "pkcs8", format: "pem" }) as string;
+import { CIPHER_OID_MAP, DIGEST_OID_TO_HASH } from "./pki-scep-types";
- const forgePrivateKey = forge.pki.privateKeyFromPem(privateKeyPem);
- const decrypted = forgePrivateKey.decrypt(forge.util.createBuffer(encryptedKey).getBytes(), "RSAES-PKCS1-V1_5");
+export { rsaPkcs1Decrypt, rsaPkcs1Encrypt, rsaSign } from "@app/lib/crypto/rsa";
- return Buffer.from(decrypted, "binary");
-};
+const { nativeCrypto, randomBytes } = crypto;
export const symmetricDecrypt = (encryptedContent: Buffer, key: Buffer, iv: Buffer, cipherOid: string): Buffer => {
const cipherInfo = CIPHER_OID_MAP[cipherOid];
@@ -25,7 +14,7 @@ export const symmetricDecrypt = (encryptedContent: Buffer, key: Buffer, iv: Buff
throw new BadRequestError({ message: `Unsupported cipher OID: ${cipherOid}` });
}
- const decipher = nodeCrypto.createDecipheriv(cipherInfo.algorithm, key, iv);
+ const decipher = nativeCrypto.createDecipheriv(cipherInfo.algorithm, key, iv);
return Buffer.concat([decipher.update(encryptedContent), decipher.final()]);
};
@@ -36,63 +25,26 @@ export const symmetricEncryptWithOid = (
const resolvedOid = cipherOid && CIPHER_OID_MAP[cipherOid] ? cipherOid : "2.16.840.1.101.3.4.1.42"; // default AES-256-CBC
const cipherInfo = CIPHER_OID_MAP[resolvedOid];
- const key = nodeCrypto.randomBytes(cipherInfo.keyLength);
- const iv = nodeCrypto.randomBytes(cipherInfo.ivLength);
+ const key = randomBytes(cipherInfo.keyLength);
+ const iv = randomBytes(cipherInfo.ivLength);
- const cipher = nodeCrypto.createCipheriv(cipherInfo.algorithm, key, iv);
+ const cipher = nativeCrypto.createCipheriv(cipherInfo.algorithm, key, iv);
const encryptedContent = Buffer.concat([cipher.update(content), cipher.final()]);
return { encryptedContent, key, iv, cipherOid: resolvedOid };
};
-export const rsaPkcs1Encrypt = (key: Buffer, recipientPublicKeyDer: Buffer): Buffer => {
- const publicKey = nodeCrypto.createPublicKey({
- key: recipientPublicKeyDer,
- format: "der",
- type: "spki"
- });
-
- return nodeCrypto.publicEncrypt(
- {
- key: publicKey,
- padding: nodeCrypto.constants.RSA_PKCS1_PADDING
- },
- key
- );
-};
-
-export const rsaSign = (data: Buffer, privateKeyDer: Buffer): Buffer => {
- const privateKey = nodeCrypto.createPrivateKey({
- key: privateKeyDer,
- format: "der",
- type: "pkcs8"
- });
-
- const signer = nodeCrypto.createSign("RSA-SHA256");
- signer.update(data);
- return signer.sign(privateKey);
-};
-
-const DIGEST_OID_TO_ALGO: Record<string, string> = {
- "2.16.840.1.101.3.4.2.1": "RSA-SHA256",
- "1.3.14.3.2.26": "RSA-SHA1",
- "2.16.840.1.101.3.4.2.2": "RSA-SHA384",
- "2.16.840.1.101.3.4.2.3": "RSA-SHA512"
-};
-
+// SCEP-specific wrapper: resolves digest algorithm OID to hash name before calling the generic rsaVerify
export const rsaVerify = (
data: Buffer,
signature: Buffer,
certificateDer: Buffer,
digestAlgorithmOid: string
): boolean => {
- const algo = DIGEST_OID_TO_ALGO[digestAlgorithmOid];
- if (!algo) {
+ const hashName = DIGEST_OID_TO_HASH[digestAlgorithmOid];
+ if (!hashName) {
throw new BadRequestError({ message: `Unsupported digest algorithm OID for verification: ${digestAlgorithmOid}` });
}
- const cert = new nodeCrypto.X509Certificate(certificateDer);
- const verifier = nodeCrypto.createVerify(algo);
- verifier.update(data);
- return verifier.verify(cert.publicKey, signature);
+ return rsaVerifyGeneric(data, signature, certificateDer, hashName);
};
diff --git a/backend/src/ee/services/pki-scep/pki-scep-fns.ts b/backend/src/ee/services/pki-scep/pki-scep-fns.ts
index dc17140189..f573a3373b 100644
--- a/backend/src/ee/services/pki-scep/pki-scep-fns.ts
+++ b/backend/src/ee/services/pki-scep/pki-scep-fns.ts
@@ -1,7 +1,14 @@
-import crypto from "node:crypto";
-
import * as x509 from "@peculiar/x509";
+import { extractX509CertFromChain } from "@app/lib/certificates/extract-certificate";
+import { crypto } from "@app/lib/crypto/cryptography";
+import { isCertChainValid } from "@app/services/certificate/certificate-fns";
+import { TCertificateAuthorityCertDALFactory } from "@app/services/certificate-authority/certificate-authority-cert-dal";
+import { TCertificateAuthorityDALFactory } from "@app/services/certificate-authority/certificate-authority-dal";
+import { getCaCertChains } from "@app/services/certificate-authority/certificate-authority-fns";
+import { TKmsServiceFactory } from "@app/services/kms/kms-service";
+import { TProjectDALFactory } from "@app/services/project/project-dal";
+
const RA_CERT_VALIDITY_YEARS = 10;
export const generateRaCertificate = async (
@@ -11,9 +18,7 @@ export const generateRaCertificate = async (
certificatePem: string;
expiresAt: Date;
}> => {
- x509.cryptoProvider.set(crypto.webcrypto as Crypto);
-
- const keyPair = await crypto.webcrypto.subtle.generateKey(
+ const keyPair = await crypto.nativeCrypto.subtle.generateKey(
{
name: "RSASSA-PKCS1-v1_5",
modulusLength: 4096,
@@ -42,7 +47,7 @@ export const generateRaCertificate = async (
]
});
- const privateKeyDer = await crypto.webcrypto.subtle.exportKey("pkcs8", keyPair.privateKey);
+ const privateKeyDer = await crypto.nativeCrypto.subtle.exportKey("pkcs8", keyPair.privateKey);
return {
privateKeyDer,
@@ -51,6 +56,52 @@ export const generateRaCertificate = async (
};
};
+export const isSignerCertIssuedByCa = async ({
+ signerCertDer,
+ caId,
+ certificateAuthorityCertDAL,
+ certificateAuthorityDAL,
+ projectDAL,
+ kmsService
+}: {
+ signerCertDer: Buffer;
+ caId: string;
+ certificateAuthorityCertDAL: Pick<TCertificateAuthorityCertDALFactory, "find" | "findById">;
+ certificateAuthorityDAL: Pick<TCertificateAuthorityDALFactory, "findById">;
+ projectDAL: Pick<TProjectDALFactory, "findOne" | "updateById" | "transaction">;
+ kmsService: Pick<TKmsServiceFactory, "decryptWithKmsKey" | "generateKmsKey">;
+}): Promise<boolean> => {
+ try {
+ const signerCert = new x509.X509Certificate(signerCertDer);
+
+ if (new Date() > signerCert.notAfter) {
+ return false;
+ }
+
+ const caCertChains = await getCaCertChains({
+ caId,
+ certificateAuthorityCertDAL,
+ certificateAuthorityDAL,
+ projectDAL,
+ kmsService
+ });
+
+ const verifiedChains = await Promise.all(
+ caCertChains.map(async (chain) => {
+ const caCert = new x509.X509Certificate(chain.certificate);
+ const chainCerts = chain.certificateChain
+ ? extractX509CertFromChain(chain.certificateChain).map((c) => new x509.X509Certificate(c))
+ : [];
+ return isCertChainValid([signerCert, caCert, ...chainCerts]);
+ })
+ );
+
+ return verifiedChains.some(Boolean);
+ } catch {
+ return false;
+ }
+};
+
export const getScepCapabilities = ({ allowCertBasedRenewal }: { allowCertBasedRenewal: boolean }): string => {
const caps = ["POSTPKIOperation", "SHA-256", "SHA-1", "AES", "DES3", "SCEPStandard"];
if (allowCertBasedRenewal) {
diff --git a/backend/src/ee/services/pki-scep/pki-scep-message-builder.ts b/backend/src/ee/services/pki-scep/pki-scep-message-builder.ts
index e05a155c03..948e1cd13f 100644
--- a/backend/src/ee/services/pki-scep/pki-scep-message-builder.ts
+++ b/backend/src/ee/services/pki-scep/pki-scep-message-builder.ts
@@ -1,5 +1,3 @@
-import nodeCrypto from "node:crypto";
-
import * as asn1js from "asn1js";
import {
AlgorithmIdentifier,
@@ -13,6 +11,8 @@ import {
SignerInfo
} from "pkijs";
+import { crypto } from "@app/lib/crypto/cryptography";
+
import { buildResponseAttributes } from "./pki-scep-attributes";
import { rsaPkcs1Encrypt, rsaSign, symmetricEncryptWithOid } from "./pki-scep-crypto";
import { ScepFailInfo, ScepPkiStatus } from "./pki-scep-types";
@@ -53,7 +53,7 @@ export const buildCertRepSuccess = ({
// Step 2: Encrypt the cert payload in an EnvelopedData for the device
// Extract the device's public key from its self-signed certificate
- const recipientCert = new nodeCrypto.X509Certificate(recipientCertDer);
+ const recipientCert = new crypto.nativeCrypto.X509Certificate(recipientCertDer);
const recipientPublicKeyDer = Buffer.from(recipientCert.publicKey.export({ type: "spki", format: "der" }));
const { encryptedContent, key: cek, iv, cipherOid } = symmetricEncryptWithOid(certPayload, clientCipherOid);
@@ -76,7 +76,7 @@ export const buildCertRepSuccess = ({
const innerContentInfoDer = Buffer.from(innerContentInfo.toBER(false));
// Step 3: Build the outer SignedData
- const senderNonce = nodeCrypto.randomBytes(16);
+ const senderNonce = crypto.randomBytes(16);
const responseAttrs = buildResponseAttributes({
transactionId,
recipientNonce,
@@ -99,7 +99,7 @@ export const buildCertRepPending = ({
transactionId: string;
recipientNonce: Buffer;
}): Buffer => {
- const senderNonce = nodeCrypto.randomBytes(16);
+ const senderNonce = crypto.randomBytes(16);
const responseAttrs = buildResponseAttributes({
transactionId,
recipientNonce,
@@ -124,7 +124,7 @@ export const buildCertRepFailure = ({
recipientNonce: Buffer;
failInfo: ScepFailInfo;
}): Buffer => {
- const senderNonce = nodeCrypto.randomBytes(16);
+ const senderNonce = crypto.randomBytes(16);
const responseAttrs = buildResponseAttributes({
transactionId,
recipientNonce,
@@ -167,7 +167,7 @@ const buildSignedCertRep = (
type: "1.2.840.113549.1.9.4", // messageDigest
values: [
new asn1js.OctetString({
- valueHex: nodeCrypto
+ valueHex: crypto.nativeCrypto
.createHash("sha256")
.update(Buffer.from(innerContent || Buffer.alloc(0)))
.digest()
diff --git a/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts b/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts
index 4fc071548a..a4057d446c 100644
--- a/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts
+++ b/backend/src/ee/services/pki-scep/pki-scep-message-parser.ts
@@ -1,13 +1,12 @@
-import nodeCrypto from "node:crypto";
-
import * as asn1js from "asn1js";
import { Certificate, type CertificateSetItem, ContentInfo, SignedData, type SignerInfo as PkiSignerInfo } from "pkijs";
+import { crypto } from "@app/lib/crypto/cryptography";
import { BadRequestError } from "@app/lib/errors";
import { extractScepAttributes } from "./pki-scep-attributes";
import { rsaPkcs1Decrypt, rsaVerify, symmetricDecrypt } from "./pki-scep-crypto";
-import { ScepMessageType, TParsedScepMessage } from "./pki-scep-types";
+import { DIGEST_OID_TO_HASH, ScepMessageType, TParsedScepMessage } from "./pki-scep-types";
export const parseScepMessage = (derMessage: Buffer, raPrivateKeyDer: Buffer): TParsedScepMessage => {
// Parse the outer ContentInfo
@@ -49,14 +48,6 @@ export const parseScepMessage = (derMessage: Buffer, raPrivateKeyDer: Buffer): T
const scepAttrs = extractScepAttributes(signerInfo.signedAttrs.attributes);
- // Verify messageDigest attribute matches the hash of the encapsulated content (RFC 5652 §11.2)
- const DIGEST_OID_TO_HASH: Record<string, string> = {
- "2.16.840.1.101.3.4.2.1": "sha256",
- "1.3.14.3.2.26": "sha1",
- "2.16.840.1.101.3.4.2.2": "sha384",
- "2.16.840.1.101.3.4.2.3": "sha512"
- };
-
// RFC 5652 §11.2: messageDigest MUST be present when signedAttrs is present
const messageDigestAttr = signerInfo.signedAttrs.attributes.find((a) => a.type === "1.2.840.113549.1.9.4");
if (!messageDigestAttr || messageDigestAttr.values.length === 0) {
@@ -77,7 +68,7 @@ export const parseScepMessage = (derMessage: Buffer, raPrivateKeyDer: Buffer): T
eContentParsed.result instanceof asn1js.OctetString
? Buffer.from(eContentParsed.result.getValue())
: Buffer.from(eContentBer);
- const computedDigest = nodeCrypto.createHash(hashAlgo).update(eContentBytes).digest();
+ const computedDigest = crypto.nativeCrypto.createHash(hashAlgo).update(eContentBytes).digest();
if (!claimedDigest.equals(computedDigest)) {
throw new BadRequestError({ message: "SCEP message integrity check failed: messageDigest mismatch" });
diff --git a/backend/src/ee/services/pki-scep/pki-scep-service.ts b/backend/src/ee/services/pki-scep/pki-scep-service.ts
index 2f9f7af2ec..4c19006425 100644
--- a/backend/src/ee/services/pki-scep/pki-scep-service.ts
+++ b/backend/src/ee/services/pki-scep/pki-scep-service.ts
@@ -1,19 +1,25 @@
import * as x509 from "@peculiar/x509";
-import RE2 from "re2";
import { extractX509CertFromChain } from "@app/lib/certificates/extract-certificate";
import { crypto } from "@app/lib/crypto/cryptography";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { ActorType } from "@app/services/auth/auth-type";
import { TCertificateBodyDALFactory } from "@app/services/certificate/certificate-body-dal";
-import { isCertChainValid } from "@app/services/certificate/certificate-fns";
import { TCertificateAuthorityCertDALFactory } from "@app/services/certificate-authority/certificate-authority-cert-dal";
import { TCertificateAuthorityDALFactory } from "@app/services/certificate-authority/certificate-authority-dal";
-import { getCaCertChain, getCaCertChains } from "@app/services/certificate-authority/certificate-authority-fns";
+import { CaType } from "@app/services/certificate-authority/certificate-authority-enums";
+import { getCaCertChain } from "@app/services/certificate-authority/certificate-authority-fns";
+import { TCertificateIssuanceQueueFactory } from "@app/services/certificate-authority/certificate-issuance-queue";
+import {
+ extractAlgorithmsFromCSR,
+ extractCertificateRequestFromCSR
+} from "@app/services/certificate-common/certificate-csr-utils";
import { TCertificatePolicyDALFactory } from "@app/services/certificate-policy/certificate-policy-dal";
+import { TCertificatePolicyServiceFactory } from "@app/services/certificate-policy/certificate-policy-service";
import { TCertificateProfileDALFactory } from "@app/services/certificate-profile/certificate-profile-dal";
import { EnrollmentType } from "@app/services/certificate-profile/certificate-profile-types";
import { TCertificateRequestDALFactory } from "@app/services/certificate-request/certificate-request-dal";
+import { TCertificateRequestServiceFactory } from "@app/services/certificate-request/certificate-request-service";
import { CertificateRequestStatus } from "@app/services/certificate-request/certificate-request-types";
import { resolveEffectiveTtl } from "@app/services/certificate-v3/certificate-v3-fns";
import { TCertificateV3ServiceFactory } from "@app/services/certificate-v3/certificate-v3-service";
@@ -25,7 +31,7 @@ import { getProjectKmsCertificateKeyId } from "@app/services/project/project-fns
import { EventType, TAuditLogServiceFactory } from "../audit-log/audit-log-types";
import { convertRawCertsToPkcs7 } from "../certificate-est/certificate-est-fns";
import { TLicenseServiceFactory } from "../license/license-service";
-import { getScepCapabilities } from "./pki-scep-fns";
+import { getScepCapabilities, isSignerCertIssuedByCa } from "./pki-scep-fns";
import { buildCertRepFailure, buildCertRepPending, buildCertRepSuccess } from "./pki-scep-message-builder";
import { parseScepMessage } from "./pki-scep-message-parser";
import { TScepTransactionDALFactory } from "./pki-scep-transaction-dal";
@@ -51,6 +57,9 @@ type TPkiScepServiceFactoryDep = {
kmsService: Pick<TKmsServiceFactory, "decryptWithKmsKey" | "generateKmsKey">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
certificatePolicyDAL: Pick<TCertificatePolicyDALFactory, "findById">;
+ certificatePolicyService: Pick<TCertificatePolicyServiceFactory, "validateCertificateRequest">;
+ certificateRequestService: Pick<TCertificateRequestServiceFactory, "createCertificateRequest">;
+ certificateIssuanceQueue: Pick<TCertificateIssuanceQueueFactory, "queueCertificateIssuance">;
auditLogService: Pick<TAuditLogServiceFactory, "createAuditLog">;
};
@@ -71,6 +80,9 @@ export const pkiScepServiceFactory = ({
kmsService,
licenseService,
certificatePolicyDAL,
+ certificatePolicyService,
+ certificateRequestService,
+ certificateIssuanceQueue,
auditLogService
}: TPkiScepServiceFactoryDep) => {
const loadScepContext = async (profileId: string) => {
@@ -88,8 +100,14 @@ export const pkiScepServiceFactory = ({
}
if (!profile.caId) {
- throw new BadRequestError({ message: "Self-signed certificates are not supported for SCEP enrollment" });
+ throw new BadRequestError({ message: "SCEP enrollment requires a Certificate Authority" });
+ }
+
+ const ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(profile.caId);
+ if (!ca) {
+ throw new NotFoundError({ message: "Certificate Authority not found" });
}
+ const caType: CaType = (ca.externalCa?.type as CaType) ?? CaType.INTERNAL;
const scepConfig = await scepEnrollmentConfigDAL.findById(profile.scepConfigId);
if (!scepConfig) {
@@ -119,7 +137,7 @@ export const pkiScepServiceFactory = ({
const raCert = new x509.X509Certificate(scepConfig.raCertificate);
const raCertDer = Buffer.from(raCert.rawData);
- return { profile, scepConfig, project, raPrivateKeyDer, raCertDer };
+ return { profile, scepConfig, project, ca, caType, raPrivateKeyDer, raCertDer } as const;
};
const getCaCaps = async ({ profileId }: TGetCaCapsDTO): Promise<string> => {
@@ -134,30 +152,29 @@ export const pkiScepServiceFactory = ({
};
const getCaCert = async ({ profileId }: TGetCaCertDTO): Promise<Buffer> => {
- const { profile, scepConfig } = await loadScepContext(profileId);
+ const { scepConfig, ca, caType } = await loadScepContext(profileId);
const raCert = new x509.X509Certificate(scepConfig.raCertificate);
const rawCerts: ArrayBuffer[] = [raCert.rawData];
- if (scepConfig.includeCaCertInResponse && profile.caId) {
- const ca = await certificateAuthorityDAL.findByIdWithAssociatedCa(profile.caId);
- if (ca?.internalCa?.activeCaCertId) {
- const { caCert, caCertChain } = await getCaCertChain({
- caCertId: ca.internalCa.activeCaCertId,
- certificateAuthorityDAL,
- certificateAuthorityCertDAL,
- projectDAL,
- kmsService
- });
+ // For internal CAs, include the CA certificate chain if configured.
+ // External CAs don't have a local CA chain, so only the RA cert is returned.
+ if (caType === CaType.INTERNAL && scepConfig.includeCaCertInResponse && ca?.internalCa?.activeCaCertId) {
+ const { caCert, caCertChain } = await getCaCertChain({
+ caCertId: ca.internalCa.activeCaCertId,
+ certificateAuthorityDAL,
+ certificateAuthorityCertDAL,
+ projectDAL,
+ kmsService
+ });
- const caCertObj = new x509.X509Certificate(caCert);
- rawCerts.push(caCertObj.rawData);
+ const caCertObj = new x509.X509Certificate(caCert);
+ rawCerts.push(caCertObj.rawData);
- if (caCertChain) {
- const chainCerts = extractX509CertFromChain(caCertChain);
- for (const cert of chainCerts) {
- rawCerts.push(new x509.X509Certificate(cert).rawData);
- }
+ if (caCertChain) {
+ const chainCerts = extractX509CertFromChain(caCertChain);
+ for (const cert of chainCerts) {
+ rawCerts.push(new x509.X509Certificate(cert).rawData);
}
}
}
@@ -169,9 +186,7 @@ export const pkiScepServiceFactory = ({
type TScepContext = Awaited<ReturnType<typeof loadScepContext>>;
const derToPem = (der: Buffer, label: string): string => {
- const re = new RE2("(.{64})", "g");
- const base64 = re.replace(der.toString("base64"), "$1\n");
- return `-----BEGIN ${label}-----\n${base64}\n-----END ${label}-----`;
+ return x509.PemConverter.encode(der, label);
};
const resolveIssuanceParams = async (profile: TScepContext["profile"]) => {
@@ -188,7 +203,7 @@ export const pkiScepServiceFactory = ({
};
const handlePkiOperation = async ({ profileId, message, clientIp }: THandlePkiOperationDTO): Promise<Buffer> => {
- const { profile, scepConfig, project, raPrivateKeyDer, raCertDer } = await loadScepContext(profileId);
+ const { profile, scepConfig, project, caType, raPrivateKeyDer, raCertDer } = await loadScepContext(profileId);
const parsed = parseScepMessage(message, raPrivateKeyDer);
@@ -199,6 +214,7 @@ export const pkiScepServiceFactory = ({
profile,
scepConfig,
project,
+ caType,
raPrivateKeyDer,
raCertDer,
parsed,
@@ -211,6 +227,7 @@ export const pkiScepServiceFactory = ({
profile,
scepConfig,
project,
+ caType,
raPrivateKeyDer,
raCertDer,
parsed,
@@ -231,43 +248,11 @@ export const pkiScepServiceFactory = ({
}
};
- // Check if a signer certificate was issued by the profile's CA
- const isSignerCertIssuedByCa = async (signerCertDer: Buffer, profile: TScepContext["profile"]): Promise<boolean> => {
- try {
- const signerCert = new x509.X509Certificate(signerCertDer);
-
- if (new Date() > signerCert.notAfter) {
- return false;
- }
-
- const caCertChains = await getCaCertChains({
- caId: profile.caId!,
- certificateAuthorityCertDAL,
- certificateAuthorityDAL,
- projectDAL,
- kmsService
- });
-
- const verifiedChains = await Promise.all(
- caCertChains.map(async (chain) => {
- const caCert = new x509.X509Certificate(chain.certificate);
- const chainCerts = chain.certificateChain
- ? extractX509CertFromChain(chain.certificateChain).map((c) => new x509.X509Certificate(c))
- : [];
- return isCertChainValid([signerCert, caCert, ...chainCerts]);
- })
- );
-
- return verifiedChains.some(Boolean);
- } catch {
- return false;
- }
- };
-
const handleEnrollment = async ({
profile,
scepConfig,
project,
+ caType,
raPrivateKeyDer,
raCertDer,
parsed,
@@ -276,6 +261,7 @@ export const pkiScepServiceFactory = ({
profile: TScepContext["profile"];
scepConfig: TScepContext["scepConfig"];
project: TScepContext["project"];
+ caType: CaType;
raPrivateKeyDer: Buffer;
raCertDer: Buffer;
parsed: TParsedScepMessage;
@@ -325,14 +311,24 @@ export const pkiScepServiceFactory = ({
// Many SCEP clients (including sscep) send PKCSReq for both initial enrollment
// and renewal — they don't use RenewalReq (messageType=17). Detect renewal by
// checking if the signer cert chains to the profile CA.
- if (scepConfig.allowCertBasedRenewal) {
- const isRenewalViaPKCSReq = await isSignerCertIssuedByCa(parsed.signerCertDer, profile);
+ // Cert-based renewal requires the CA chain for verification, so it's only
+ // supported for internal CAs (not external CAs).
+ if (scepConfig.allowCertBasedRenewal && caType === CaType.INTERNAL) {
+ const isRenewalViaPKCSReq = await isSignerCertIssuedByCa({
+ signerCertDer: parsed.signerCertDer,
+ caId: profile.caId!,
+ certificateAuthorityCertDAL,
+ certificateAuthorityDAL,
+ projectDAL,
+ kmsService
+ });
if (isRenewalViaPKCSReq) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
return handleRenewal({
profile,
scepConfig,
project,
+ caType,
raPrivateKeyDer,
raCertDer,
parsed,
@@ -374,53 +370,32 @@ export const pkiScepServiceFactory = ({
const { ttl } = await resolveIssuanceParams(profile);
const csrPem = derToPem(Buffer.from(parsed.csr), "CERTIFICATE REQUEST");
- const result = await certificateV3Service.signCertificateFromProfile({
- actor: ActorType.SCEP_ACCOUNT,
- actorId: profile.id,
- actorAuthMethod: null,
- actorOrgId: project.orgId,
- profileId: profile.id,
- csr: csrPem,
- validity: { ttl },
- enrollmentType: EnrollmentType.SCEP
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
+ const result = await issueOrQueueCertificate({
+ profile,
+ project,
+ caType,
+ parsed,
+ csrPem,
+ ttl
});
- if (result.status === CertificateRequestStatus.PENDING_APPROVAL) {
- // If the client retries with the same transactionId (e.g. network hiccup),
- // return PENDING instead of crashing on unique-constraint violation.
- const existingTx = await scepTransactionDAL.findByProfileAndTransactionId(profile.id, parsed.transactionId);
- if (!existingTx) {
- const expiresAt = new Date();
- expiresAt.setHours(expiresAt.getHours() + SCEP_TRANSACTION_EXPIRY_HOURS);
-
- await scepTransactionDAL.create({
- profileId: profile.id,
- transactionId: parsed.transactionId,
- senderNonce: parsed.senderNonce,
- signerCertDer: parsed.signerCertDer,
- certificateRequestId: result.certificateRequestId,
- clientCipherOid: parsed.clientCipherOid || null,
- expiresAt
- });
- }
+ const auditMetadata = {
+ profileId: profile.id,
+ profileSlug: profile.slug,
+ transactionId: parsed.transactionId,
+ csrSubject: csrObj.subject,
+ challengeType: "static" as const,
+ clientIp
+ };
+ if (result.status === "pending") {
void auditLogService.createAuditLog({
projectId: profile.projectId,
- actor: {
- type: ActorType.SCEP_ACCOUNT,
- metadata: { profileId: profile.id }
- },
+ actor: { type: ActorType.SCEP_ACCOUNT, metadata: { profileId: profile.id } },
event: {
type: EventType.SCEP_ENROLLMENT,
- metadata: {
- profileId: profile.id,
- profileSlug: profile.slug,
- transactionId: parsed.transactionId,
- csrSubject: csrObj.subject,
- challengeType: "static" as const,
- status: "pending" as const,
- clientIp
- }
+ metadata: { ...auditMetadata, status: "pending" as const }
}
});
@@ -432,37 +407,22 @@ export const pkiScepServiceFactory = ({
});
}
- if (!result.certificate) {
- throw new BadRequestError({ message: "Certificate issuance failed" });
- }
-
- const issuedCert = new x509.X509Certificate(result.certificate);
- const issuedCertDer = Buffer.from(issuedCert.rawData);
-
void auditLogService.createAuditLog({
projectId: profile.projectId,
- actor: {
- type: ActorType.SCEP_ACCOUNT,
- metadata: { profileId: profile.id }
- },
+ actor: { type: ActorType.SCEP_ACCOUNT, metadata: { profileId: profile.id } },
event: {
type: EventType.SCEP_ENROLLMENT,
metadata: {
- profileId: profile.id,
- profileSlug: profile.slug,
- transactionId: parsed.transactionId,
- csrSubject: csrObj.subject,
- challengeType: "static" as const,
+ ...auditMetadata,
status: "success" as const,
issuedCertificateId: result.certificateId,
- issuedSerialNumber: result.serialNumber,
- clientIp
+ issuedSerialNumber: result.serialNumber
}
}
});
return buildCertRepSuccess({
- issuedCertDer,
+ issuedCertDer: result.issuedCertDer,
recipientCertDer: parsed.signerCertDer,
raCertDer,
raPrivateKeyDer,
@@ -476,6 +436,7 @@ export const pkiScepServiceFactory = ({
profile,
scepConfig,
project,
+ caType,
raPrivateKeyDer,
raCertDer,
parsed,
@@ -484,6 +445,7 @@ export const pkiScepServiceFactory = ({
profile: TScepContext["profile"];
scepConfig: TScepContext["scepConfig"];
project: TScepContext["project"];
+ caType: CaType;
raPrivateKeyDer: Buffer;
raCertDer: Buffer;
parsed: TParsedScepMessage;
@@ -505,8 +467,14 @@ export const pkiScepServiceFactory = ({
const csrObj = new x509.Pkcs10CertificateRequest(parsed.csr);
- const signerCert = new x509.X509Certificate(parsed.signerCertDer);
- const isValidSigner = await isSignerCertIssuedByCa(parsed.signerCertDer, profile);
+ const isValidSigner = await isSignerCertIssuedByCa({
+ signerCertDer: parsed.signerCertDer,
+ caId: profile.caId!,
+ certificateAuthorityCertDAL,
+ certificateAuthorityDAL,
+ projectDAL,
+ kmsService
+ });
if (!isValidSigner) {
void auditLogService.createAuditLog({
projectId: profile.projectId,
@@ -540,33 +508,33 @@ export const pkiScepServiceFactory = ({
const { ttl } = await resolveIssuanceParams(profile);
const csrPem = derToPem(Buffer.from(parsed.csr), "CERTIFICATE REQUEST");
- const result = await certificateV3Service.signCertificateFromProfile({
- actor: ActorType.SCEP_ACCOUNT,
- actorId: profile.id,
- actorAuthMethod: null,
- actorOrgId: project.orgId,
- profileId: profile.id,
- csr: csrPem,
- validity: { ttl },
- enrollmentType: EnrollmentType.SCEP
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
+ const result = await issueOrQueueCertificate({
+ profile,
+ project,
+ caType,
+ parsed,
+ csrPem,
+ ttl
});
- if (result.status === CertificateRequestStatus.PENDING_APPROVAL) {
- const existingTx = await scepTransactionDAL.findByProfileAndTransactionId(profile.id, parsed.transactionId);
- if (!existingTx) {
- const expiresAt = new Date();
- expiresAt.setHours(expiresAt.getHours() + SCEP_TRANSACTION_EXPIRY_HOURS);
+ const auditMetadata = {
+ profileId: profile.id,
+ profileSlug: profile.slug,
+ transactionId: parsed.transactionId,
+ csrSubject: csrObj.subject,
+ clientIp
+ };
- await scepTransactionDAL.create({
- profileId: profile.id,
- transactionId: parsed.transactionId,
- senderNonce: parsed.senderNonce,
- signerCertDer: parsed.signerCertDer,
- certificateRequestId: result.certificateRequestId,
- clientCipherOid: parsed.clientCipherOid || null,
- expiresAt
- });
- }
+ if (result.status === "pending") {
+ void auditLogService.createAuditLog({
+ projectId: profile.projectId,
+ actor: { type: ActorType.SCEP_ACCOUNT, metadata: { profileId: profile.id } },
+ event: {
+ type: EventType.SCEP_RENEWAL,
+ metadata: { ...auditMetadata, status: "pending" as const }
+ }
+ });
return buildCertRepPending({
raCertDer,
@@ -576,36 +544,22 @@ export const pkiScepServiceFactory = ({
});
}
- if (!result.certificate) {
- throw new BadRequestError({ message: "Certificate renewal failed" });
- }
-
- const issuedCert = new x509.X509Certificate(result.certificate);
-
void auditLogService.createAuditLog({
projectId: profile.projectId,
- actor: {
- type: ActorType.SCEP_ACCOUNT,
- metadata: { profileId: profile.id }
- },
+ actor: { type: ActorType.SCEP_ACCOUNT, metadata: { profileId: profile.id } },
event: {
type: EventType.SCEP_RENEWAL,
metadata: {
- profileId: profile.id,
- profileSlug: profile.slug,
- transactionId: parsed.transactionId,
- csrSubject: csrObj.subject,
- existingCertificateSerial: signerCert.serialNumber,
+ ...auditMetadata,
status: "success" as const,
issuedCertificateId: result.certificateId,
- issuedSerialNumber: result.serialNumber,
- clientIp
+ issuedSerialNumber: result.serialNumber
}
}
});
return buildCertRepSuccess({
- issuedCertDer: Buffer.from(issuedCert.rawData),
+ issuedCertDer: result.issuedCertDer,
recipientCertDer: parsed.signerCertDer,
raCertDer,
raPrivateKeyDer,
@@ -615,6 +569,157 @@ export const pkiScepServiceFactory = ({
});
};
+ type TIssuanceResult =
+ | { status: "pending" }
+ | { status: "success"; issuedCertDer: Buffer; certificateId?: string; serialNumber?: string };
+
+ // For internal CAs signs directly via signCertificateFromProfile.
+ // For external CAs, creates a cert request and queues async issuance.
+ const issueOrQueueCertificate = async ({
+ profile,
+ project,
+ caType,
+ parsed,
+ csrPem,
+ ttl
+ }: {
+ profile: TScepContext["profile"];
+ project: TScepContext["project"];
+ caType: CaType;
+ parsed: TParsedScepMessage;
+ csrPem: string;
+ ttl: string;
+ }): Promise<TIssuanceResult> => {
+ // Internal CAs use direct signing
+ if (caType === CaType.INTERNAL) {
+ const result = await certificateV3Service.signCertificateFromProfile({
+ actor: ActorType.SCEP_ACCOUNT,
+ actorId: profile.id,
+ actorAuthMethod: null,
+ actorOrgId: project.orgId,
+ profileId: profile.id,
+ csr: csrPem,
+ validity: { ttl },
+ enrollmentType: EnrollmentType.SCEP
+ });
+
+ if (result.status === CertificateRequestStatus.PENDING_APPROVAL) {
+ const existingTx = await scepTransactionDAL.findByProfileAndTransactionId(profile.id, parsed.transactionId);
+ if (!existingTx) {
+ const expiresAt = new Date();
+ expiresAt.setHours(expiresAt.getHours() + SCEP_TRANSACTION_EXPIRY_HOURS);
+
+ await scepTransactionDAL.create({
+ profileId: profile.id,
+ transactionId: parsed.transactionId,
+ senderNonce: parsed.senderNonce,
+ signerCertDer: parsed.signerCertDer,
+ certificateRequestId: result.certificateRequestId,
+ clientCipherOid: parsed.clientCipherOid || null,
+ expiresAt
+ });
+ }
+
+ return { status: "pending" };
+ }
+
+ if (!result.certificate) {
+ throw new BadRequestError({ message: "Certificate issuance failed" });
+ }
+
+ return {
+ status: "success",
+ issuedCertDer: Buffer.from(new x509.X509Certificate(result.certificate).rawData),
+ certificateId: result.certificateId,
+ serialNumber: result.serialNumber
+ };
+ }
+
+ // External CA: validate policy, create cert request, queue async issuance
+ if (!profile.certificatePolicyId) {
+ throw new BadRequestError({ message: "Certificate policy is required for external CA issuance" });
+ }
+
+ const certRequest = extractCertificateRequestFromCSR(csrPem);
+ const { keyAlgorithm, signatureAlgorithm } = extractAlgorithmsFromCSR(csrPem);
+
+ const validationResult = await certificatePolicyService.validateCertificateRequest(profile.certificatePolicyId, {
+ ...certRequest,
+ keyAlgorithm,
+ signatureAlgorithm,
+ validity: { ttl }
+ });
+ if (!validationResult.isValid) {
+ throw new BadRequestError({
+ message: `Certificate request validation failed: ${validationResult.errors.join(", ")}`
+ });
+ }
+
+ const newCertRequest = await certificateRequestService.createCertificateRequest({
+ actor: ActorType.SCEP_ACCOUNT,
+ actorId: profile.id,
+ actorAuthMethod: null,
+ actorOrgId: project.orgId,
+ projectId: profile.projectId,
+ caId: profile.caId!,
+ profileId: profile.id,
+ commonName: certRequest.commonName ?? "",
+ keyUsages: certRequest.keyUsages?.map((u) => u.toString()) ?? [],
+ extendedKeyUsages: certRequest.extendedKeyUsages?.map((u) => u.toString()) ?? [],
+ keyAlgorithm: keyAlgorithm || "",
+ signatureAlgorithm: signatureAlgorithm || "",
+ altNames: certRequest.subjectAlternativeNames,
+ csr: csrPem,
+ ttl,
+ status: CertificateRequestStatus.PENDING,
+ enrollmentType: EnrollmentType.SCEP,
+ organization: certRequest.organization,
+ organizationalUnit: certRequest.organizationalUnit,
+ country: certRequest.country,
+ state: certRequest.state,
+ locality: certRequest.locality
+ });
+
+ await certificateIssuanceQueue.queueCertificateIssuance({
+ certificateId: newCertRequest.id,
+ profileId: profile.id,
+ caId: profile.caId!,
+ ttl,
+ signatureAlgorithm: signatureAlgorithm || "",
+ keyAlgorithm: keyAlgorithm || "",
+ commonName: certRequest.commonName || "",
+ altNames: certRequest.subjectAlternativeNames?.map((san) => ({ type: san.type, value: san.value })) || [],
+ keyUsages: certRequest.keyUsages?.map((u) => u.toString()) ?? [],
+ extendedKeyUsages: certRequest.extendedKeyUsages?.map((u) => u.toString()) ?? [],
+ certificateRequestId: newCertRequest.id,
+ csr: csrPem,
+ organization: certRequest.organization,
+ organizationalUnit: certRequest.organizationalUnit,
+ country: certRequest.country,
+ state: certRequest.state,
+ locality: certRequest.locality
+ });
+
+ // Create SCEP transaction so the client can poll via GetCertInitial
+ const existingTx = await scepTransactionDAL.findByProfileAndTransactionId(profile.id, parsed.transactionId);
+ if (!existingTx) {
+ const expiresAt = new Date();
+ expiresAt.setHours(expiresAt.getHours() + SCEP_TRANSACTION_EXPIRY_HOURS);
+
+ await scepTransactionDAL.create({
+ profileId: profile.id,
+ transactionId: parsed.transactionId,
+ senderNonce: parsed.senderNonce,
+ signerCertDer: parsed.signerCertDer,
+ certificateRequestId: newCertRequest.id,
+ clientCipherOid: parsed.clientCipherOid || null,
+ expiresAt
+ });
+ }
+
+ return { status: "pending" };
+ };
+
const handleGetCertInitial = async ({
profile,
raPrivateKeyDer,
@@ -671,6 +776,7 @@ export const pkiScepServiceFactory = ({
switch (certRequest.status) {
case CertificateRequestStatus.PENDING_APPROVAL:
+ case CertificateRequestStatus.PENDING:
return buildCertRepPending({
raCertDer,
raPrivateKeyDer,
diff --git a/backend/src/ee/services/pki-scep/pki-scep-types.ts b/backend/src/ee/services/pki-scep/pki-scep-types.ts
index 135b4a3e7e..f752fb81c6 100644
--- a/backend/src/ee/services/pki-scep/pki-scep-types.ts
+++ b/backend/src/ee/services/pki-scep/pki-scep-types.ts
@@ -28,6 +28,13 @@ export const SCEP_OIDS = {
recipientNonce: "2.16.840.1.113733.1.9.6"
} as const;
+export const DIGEST_OID_TO_HASH: Record<string, string> = {
+ "2.16.840.1.101.3.4.2.1": "sha256",
+ "1.3.14.3.2.26": "sha1",
+ "2.16.840.1.101.3.4.2.2": "sha384",
+ "2.16.840.1.101.3.4.2.3": "sha512"
+};
+
export const CIPHER_OID_MAP: Record<string, { algorithm: string; keyLength: number; ivLength: number }> = {
"2.16.840.1.101.3.4.1.2": { algorithm: "aes-128-cbc", keyLength: 16, ivLength: 16 }, // AES-128-CBC
"2.16.840.1.101.3.4.1.42": { algorithm: "aes-256-cbc", keyLength: 32, ivLength: 16 }, // AES-256-CBC
diff --git a/backend/src/lib/crypto/index.ts b/backend/src/lib/crypto/index.ts
index aac797a3e3..dd12c92da7 100644
--- a/backend/src/lib/crypto/index.ts
+++ b/backend/src/lib/crypto/index.ts
@@ -1,5 +1,6 @@
export { crypto, SymmetricKeySize } from "./cryptography";
export { buildSecretBlindIndexFromName } from "./encryption";
+export { rsaPkcs1Decrypt, rsaPkcs1Encrypt, rsaSign, rsaVerify } from "./rsa";
export {
decryptIntegrationAuths,
decryptSecretApprovals,
diff --git a/backend/src/lib/crypto/rsa.ts b/backend/src/lib/crypto/rsa.ts
new file mode 100644
index 0000000000..2e4d7e6526
--- /dev/null
+++ b/backend/src/lib/crypto/rsa.ts
@@ -0,0 +1,69 @@
+import forge from "node-forge";
+
+import { crypto } from "./cryptography";
+
+const { nativeCrypto } = crypto;
+
+/**
+ * RSA PKCS#1 v1.5 decryption using node-forge.
+ *
+ * Node.js native crypto removed RSA_PKCS1_PADDING for privateDecrypt (CVE-2023-46809).
+ * Protocols that mandate PKCS#1 v1.5 key transport (e.g. SCEP per RFC 8894) need forge.
+ */
+export const rsaPkcs1Decrypt = (encryptedKey: Buffer, privateKeyDer: Buffer): Buffer => {
+ const privateKeyPem = nativeCrypto
+ .createPrivateKey({ key: privateKeyDer, format: "der", type: "pkcs8" })
+ .export({ type: "pkcs8", format: "pem" }) as string;
+
+ const forgePrivateKey = forge.pki.privateKeyFromPem(privateKeyPem);
+ const decrypted = forgePrivateKey.decrypt(forge.util.createBuffer(encryptedKey).getBytes(), "RSAES-PKCS1-V1_5");
+
+ return Buffer.from(decrypted, "binary");
+};
+
+/**
+ * RSA PKCS#1 v1.5 encryption using node-forge.
+ * Counterpart to rsaPkcs1Decrypt — uses forge for consistency.
+ */
+export const rsaPkcs1Encrypt = (key: Buffer, recipientPublicKeyDer: Buffer): Buffer => {
+ const publicKeyPem = nativeCrypto
+ .createPublicKey({ key: recipientPublicKeyDer, format: "der", type: "spki" })
+ .export({ type: "spki", format: "pem" }) as string;
+
+ const forgePublicKey = forge.pki.publicKeyFromPem(publicKeyPem);
+ const encrypted = forgePublicKey.encrypt(forge.util.createBuffer(key).getBytes(), "RSAES-PKCS1-V1_5");
+
+ return Buffer.from(encrypted, "binary");
+};
+
+/**
+ * RSA-SHA256 signing with a DER-encoded PKCS#8 private key.
+ */
+export const rsaSign = (data: Buffer, privateKeyDer: Buffer): Buffer => {
+ const privateKey = nativeCrypto.createPrivateKey({
+ key: privateKeyDer,
+ format: "der",
+ type: "pkcs8"
+ });
+
+ const signer = nativeCrypto.createSign("RSA-SHA256");
+ signer.update(data);
+ return signer.sign(privateKey);
+};
+
+/**
+ * RSA signature verification with a DER-encoded certificate and configurable digest.
+ */
+export const rsaVerify = (
+ data: Buffer,
+ signature: Buffer,
+ certificateDer: Buffer,
+ digestAlgorithm: string
+): boolean => {
+ const algo = `RSA-${digestAlgorithm.toUpperCase()}`;
+
+ const cert = new nativeCrypto.X509Certificate(certificateDer);
+ const verifier = nativeCrypto.createVerify(algo);
+ verifier.update(data);
+ return verifier.verify(cert.publicKey, signature);
+};
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index ce34aa72a4..5b48e40d79 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -2591,6 +2591,9 @@ export const registerRoutes = async (
kmsService,
licenseService,
certificatePolicyDAL,
+ certificatePolicyService,
+ certificateRequestService,
+ certificateIssuanceQueue,
auditLogService
});
diff --git a/backend/src/services/certificate-profile/certificate-profile-service.ts b/backend/src/services/certificate-profile/certificate-profile-service.ts
index 3d5adfd061..dc392b5c8e 100644
--- a/backend/src/services/certificate-profile/certificate-profile-service.ts
+++ b/backend/src/services/certificate-profile/certificate-profile-service.ts
@@ -9,6 +9,7 @@ import {
ProjectPermissionSub
} from "@app/ee/services/permission/project-permission";
import { buildUrl } from "@app/ee/services/pki-acme/pki-acme-fns";
+import { generateRaCertificate } from "@app/ee/services/pki-scep/pki-scep-fns";
import { getProcessedPermissionRules } from "@app/lib/casl/permission-filter-utils";
import { extractX509CertFromChain } from "@app/lib/certificates/extract-certificate";
import { getConfig } from "@app/lib/config/env";
@@ -420,7 +421,6 @@ export const certificateProfileServiceFactory = ({
| undefined;
if (data.enrollmentType === EnrollmentType.SCEP && data.scepConfig) {
- const { generateRaCertificate } = await import("@app/ee/services/pki-scep/pki-scep-fns");
const raCert = await generateRaCertificate(data.slug);
const certificateManagerKmsId = await getProjectKmsCertificateKeyId({
diff --git a/docs/documentation/platform/pki/enrollment-methods/scep.mdx b/docs/documentation/platform/pki/enrollment-methods/scep.mdx
index 2fde69313b..ba27c3aac5 100644
--- a/docs/documentation/platform/pki/enrollment-methods/scep.mdx
+++ b/docs/documentation/platform/pki/enrollment-methods/scep.mdx
@@ -25,11 +25,7 @@ For self-hosted Infisical instances, replace `app.infisical.com` with your insta
## Prerequisites
- A SCEP-compatible client (e.g., [sscep](https://github.com/certnanny/sscep)) or a network device with built-in SCEP support.
-- A certificate profile with a **CA-issued** issuer type. Self-signed issuer types are not supported for SCEP.
-
-<Note>
- SCEP enrollment requires an **Enterprise** plan.
-</Note>
+- A certificate profile with a **CA-issued** issuer type.
## Guide to Certificate Enrollment via SCEP
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx
index 828ae79736..6dbb20efc1 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/CreateProfileModal.tsx
@@ -1621,6 +1621,7 @@ export const CreateProfileModal = ({ isOpen, onClose, profile, mode = "create" }
isRequired={!isEdit}
isError={Boolean(error)}
errorText={error?.message}
+ helperText="The challenge password cannot be viewed after creation. Make sure to save it somewhere safe."
>
<Input
{...field}
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ScepDetailsModal.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ScepDetailsModal.tsx
index 8614308747..fc7950ca42 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ScepDetailsModal.tsx
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ScepDetailsModal.tsx
@@ -80,7 +80,7 @@ export const ScepDetailsModal = ({ isOpen, onClose, profile }: Props) => {
<FormLabel
label="RA Certificate"
className="mt-4"
- tooltipText="The Registration Authority certificate used by SCEP clients to encrypt enrollment requests."
+ tooltipText="The Registration Authority certificate used by SCEP clients."
/>
<div className="flex items-center justify-between rounded-md border border-mineshaft-600 bg-mineshaft-900 px-4 py-3">
<p className="text-xs text-mineshaft-400">Expires: {raCertExpiresAt}</p>