Skip to content

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

Fix veria finding

Carlos Monastyrski08c13e043a40
diff --git a/backend/src/services/certificate/certificate-ocsp-client.ts b/backend/src/services/certificate/certificate-ocsp-client.ts
index 6b3abedb11..57011c977a 100644
--- a/backend/src/services/certificate/certificate-ocsp-client.ts
+++ b/backend/src/services/certificate/certificate-ocsp-client.ts
@@ -12,6 +12,7 @@ import { sanitizeUrlForLog } from "@app/lib/logger/sanitize-url";
import { safeRequest } from "@app/lib/validator/safe-request";
const OCSP_CLIENT_TIMEOUT_MS = 10_000;
+const OCSP_CLIENT_MAX_RESPONSE_BYTES = 1024 * 1024;
const OCSP_CLOCK_SKEW_MS = 5 * 60 * 1000;
const OCSP_MAX_AGE_WITHOUT_NEXT_UPDATE_MS = 7 * 24 * 60 * 60 * 1000;
const PKIJS_CERT_STATUS: Record<number, OcspCertStatus> = {
@@ -69,7 +70,8 @@ export const getCertificateOcspStatus = async ({
const { data } = await safeRequest.post<ArrayBuffer>(ocspUrl, Buffer.from(ocspRequest.toSchema(true).toBER(false)), {
headers: { "Content-Type": OCSP_REQUEST_CONTENT_TYPE },
responseType: "arraybuffer",
- timeout: OCSP_CLIENT_TIMEOUT_MS
+ timeout: OCSP_CLIENT_TIMEOUT_MS,
+ maxContentLength: OCSP_CLIENT_MAX_RESPONSE_BYTES
});
const ocspResponse = pkijs.OCSPResponse.fromBER(new Uint8Array(data).buffer);
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx
index fbe5c825bb..3bf3daf32f 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx
@@ -690,6 +690,7 @@ export const CertificateRenewalModal = ({ popUp, applicationName, handlePopUpTog
const [isSeeded, setIsSeeded] = useState(false);
const seededCertificateIdRef = useRef<string | null>(null);
const seededTtlRef = useRef("");
+ const newOrderTtlRef = useRef("");
useEffect(() => {
if (!isOpen) {
seededCertificateIdRef.current = null;
@@ -707,6 +708,7 @@ export const CertificateRenewalModal = ({ popUp, applicationName, handlePopUpTog
seededCertificateIdRef.current = certificate.id;
const renewalDefaults = buildRenewalFormDefaults(certificate, constraints, renewalPreview);
seededTtlRef.current = renewalDefaults.ttl ?? "";
+ newOrderTtlRef.current = "";
// Seed the rows the policy requires so they are visible as fields from the start.
const seeded = withRequiredRows(
buildPolicyRules(policyData),
@@ -735,13 +737,13 @@ export const CertificateRenewalModal = ({ popUp, applicationName, handlePopUpTog
useEffect(() => {
if (!isSeeded || !seededTtlRef.current) return;
- setValue(
- "ttl",
- isReissuing
- ? capTtlToDays(seededTtlRef.current, REISSUE_MAX_VALIDITY_DAYS)
- : seededTtlRef.current
- );
- }, [isSeeded, isReissuing, setValue]);
+ if (isReissuing) {
+ newOrderTtlRef.current = getValues("ttl");
+ setValue("ttl", capTtlToDays(seededTtlRef.current, REISSUE_MAX_VALIDITY_DAYS));
+ return;
+ }
+ setValue("ttl", newOrderTtlRef.current || seededTtlRef.current);
+ }, [isSeeded, isReissuing, getValues, setValue]);
const closeWizard = () => {
handlePopUpToggle("renewCertificate", false);