Skip to content

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

misc: add not-before and not-after check in sign CSR

Sheen Capadnganb48cc6903d21
diff --git a/backend/src/services/certificate-v3/certificate-v3-service.ts b/backend/src/services/certificate-v3/certificate-v3-service.ts
index 9cc1addf43..532706c193 100644
--- a/backend/src/services/certificate-v3/certificate-v3-service.ts
+++ b/backend/src/services/certificate-v3/certificate-v3-service.ts
@@ -1225,7 +1225,15 @@ export const certificateV3ServiceFactory = ({
mappedCertificateRequest.keyAlgorithm = extractedKeyAlgorithm;
mappedCertificateRequest.signatureAlgorithm = extractedSignatureAlgorithm;
- mappedCertificateRequest.validity = validity;
+
+ // When notAfter is explicitly provided, validate using date range (notAfter overrides TTL in cert generation).
+ // Otherwise, validate using TTL. These are mutually exclusive to avoid "Cannot specify both" validation error.
+ if (notAfter) {
+ mappedCertificateRequest.notBefore = notBefore;
+ mappedCertificateRequest.notAfter = notAfter;
+ } else {
+ mappedCertificateRequest.validity = validity;
+ }
// Determine effective basicConstraints early (before approval flow)
// so it's available for both the approval path and direct signing path.