Skip to content

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

fix(pki): skip an imperva certificate whose key type is unsupported

bernie-gdb8e3d12606b
diff --git a/backend/src/services/pki-sync/imperva/imperva-pki-sync-fns.test.ts b/backend/src/services/pki-sync/imperva/imperva-pki-sync-fns.test.ts
index 244cfca12a..fddb3529e2 100644
--- a/backend/src/services/pki-sync/imperva/imperva-pki-sync-fns.test.ts
+++ b/backend/src/services/pki-sync/imperva/imperva-pki-sync-fns.test.ts
@@ -111,7 +111,7 @@ describe("Imperva upload failures", () => {
const rejected = new ImpervaRequestError({ message: "Invalid input", status: 400 });
expect(describeImpervaUploadFailure(rejected)).toBe(
- "Invalid input. Imperva rejected the certificate. It has to cover every domain the website serves, and its key has to be RSA under 4096 bits or ECDSA P-256"
+ "Invalid input. Imperva rejected the certificate. It has to cover at least one domain the website serves, and its key has to be RSA under 4096 bits or ECDSA P-256"
);
});
diff --git a/backend/src/services/pki-sync/imperva/imperva-pki-sync-fns.ts b/backend/src/services/pki-sync/imperva/imperva-pki-sync-fns.ts
index 77d38c0171..7bc5db09ca 100644
--- a/backend/src/services/pki-sync/imperva/imperva-pki-sync-fns.ts
+++ b/backend/src/services/pki-sync/imperva/imperva-pki-sync-fns.ts
@@ -57,7 +57,7 @@ const IMPERVA_CUSTOM_CERT_TYPE = "CUSTOM_CERT";
// Imperva answers a rejected upload with a bare "Invalid input", which tells the user nothing about
// what to change, so the conditions it enforces are spelled out alongside its message.
const IMPERVA_UPLOAD_REJECTION_HINT =
- "Imperva rejected the certificate. It has to cover every domain the website serves, and its key has to be RSA under 4096 bits or ECDSA P-256";
+ "Imperva rejected the certificate. It has to cover at least one domain the website serves, and its key has to be RSA under 4096 bits or ECDSA P-256";
// 429 aside, a 4xx is Imperva refusing the request itself, so repeating it changes nothing.
export const isImpervaRetryable = (error: unknown): boolean => {
@@ -213,6 +213,7 @@ export const impervaPkiSyncFactory = ({
certificateChain?: string;
certificateId?: string;
renewedFromCertificateId?: string | null;
+ authType: ImpervaCertificateAuthType;
};
const prepareCertificate = async (
@@ -235,6 +236,16 @@ export const impervaPkiSyncFactory = ({
continue;
}
+ const authType = resolveImpervaAuthType(cert);
+ if (!authType) {
+ skippedCertificates.push({
+ name: certName,
+ reason: `Imperva accepts only RSA and ECDSA certificates, and this one uses ${describeImpervaKeyType(cert)}`
+ });
+ // eslint-disable-next-line no-continue
+ continue;
+ }
+
if (selected) {
skippedCertificates.push({
name: certName,
@@ -258,7 +269,7 @@ export const impervaPkiSyncFactory = ({
renewedFromCertificateId = certificate?.renewedFromCertificateId;
}
- selected = { certName, cert, privateKey, certificateChain, certificateId, renewedFromCertificateId };
+ selected = { certName, cert, privateKey, certificateChain, certificateId, renewedFromCertificateId, authType };
}
return { certificate: selected, skippedCertificates };
@@ -377,16 +388,7 @@ export const impervaPkiSyncFactory = ({
const renewedFromCertificateIds: string[] = [];
if (certificate) {
- const authType = resolveImpervaAuthType(certificate.cert);
-
- if (!authType) {
- throw new PkiSyncError({
- message: `Imperva accepts only RSA and ECDSA certificates, and '${
- certificate.certName
- }' uses ${describeImpervaKeyType(certificate.cert)}`
- });
- }
-
+ const { authType } = certificate;
const externalIdentifier = buildImpervaExternalIdentifier(siteId, authType);
// Claimed up front so the slot is never held by a live certificate no record points at,