Skip to content

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

Address veria comment

Carlos Monastyrskib41c8ac31c34
diff --git a/backend/src/services/certificate-common/certificate-extension-fns.test.ts b/backend/src/services/certificate-common/certificate-extension-fns.test.ts
index 2bf2811a03..12bee08528 100644
--- a/backend/src/services/certificate-common/certificate-extension-fns.test.ts
+++ b/backend/src/services/certificate-common/certificate-extension-fns.test.ts
@@ -446,6 +446,32 @@ describe("resolveCustomExtensions", () => {
expect(toRequestCustomExtensions(stored).map((entry) => entry.oid)).toEqual([CUSTOM_OID, SID_OID]);
});
+ it("accepts no value it cannot read back, so a renewal can always reissue what a user asked for", () => {
+ const candidates = [
+ "ops-prod",
+ "a".repeat(200),
+ "h\u00e9llo",
+ " ",
+ "0",
+ "*",
+ "a,b",
+ "5",
+ "S-1-5-21-1-2-3-4",
+ "WebServer"
+ ];
+
+ for (const oid of ["1.3.6.1.4.1.99001.7", ...Object.keys(CUSTOM_EXTENSION_PRESETS_BY_OID)]) {
+ for (const candidate of candidates) {
+ if (validateCustomExtensionValue(oid, candidate) !== null) continue;
+ const stored = encodeCustomExtensionValue(oid, candidate);
+ expect(
+ describeCustomExtensionValue(oid, stored),
+ `${oid} accepted '${candidate}' but cannot read it back`
+ ).not.toBeNull();
+ }
+ }
+ });
+
it("omits an extension whose stored value cannot be read back", () => {
const stored = [{ oid: SID_OID, critical: false, value: Buffer.from([0x05, 0x00]).toString("base64") }];
@@ -714,7 +740,6 @@ describe("toRequestCustomExtensions", () => {
];
expect(toRequestCustomExtensions(stored)).toEqual([]);
- expect(toRequestCustomExtensions(stored)).toEqual([]);
});
});
@@ -728,7 +753,6 @@ describe("parseImportedCustomExtensions", () => {
expect(stored).toEqual([{ oid: "1.3.6.1.5.5.7.1.3", critical: false, value: qcStatements.toString("base64") }]);
expect(toRequestCustomExtensions(stored)).toEqual([]);
- expect(toRequestCustomExtensions(stored)).toEqual([]);
});
// Dropping must-staple would hand back a renewed certificate with a weaker security posture than
diff --git a/backend/src/services/certificate-common/certificate-extension-fns.ts b/backend/src/services/certificate-common/certificate-extension-fns.ts
index e716d08cdd..7fe3855454 100644
--- a/backend/src/services/certificate-common/certificate-extension-fns.ts
+++ b/backend/src/services/certificate-common/certificate-extension-fns.ts
@@ -380,7 +380,7 @@ export const toRequestCustomExtensions = (stored: unknown): TRequestCustomExtens
}
logger?.warn(
- `Custom extension '${extension.oid}' cannot be read back into a value a request can carry, so it is omitted`
+ `Custom extension '${extension.oid}' cannot be read back into a value a request can carry, so it is omitted [oid=${extension.oid}]`
);
return [];
}
diff --git a/backend/src/services/certificate-v3/certificate-renewal-fns.test.ts b/backend/src/services/certificate-v3/certificate-renewal-fns.test.ts
index 7b4b87b74e..af6c90b425 100644
--- a/backend/src/services/certificate-v3/certificate-renewal-fns.test.ts
+++ b/backend/src/services/certificate-v3/certificate-renewal-fns.test.ts
@@ -159,6 +159,15 @@ describe("resolveRenewalCustomExtensions", () => {
).toEqual([]);
});
+ it("omits an unreadable value rather than blocking the renewal, whichever side it came from", () => {
+ const unreadable = [{ oid: CUSTOM_OID, value: "BQA=", critical: false }];
+
+ expect(resolveRenewalCustomExtensions({ exists: true, customExtensions: unreadable }, {})).toEqual([]);
+ expect(
+ resolveRenewalCustomExtensions({ exists: false, customExtensions: null }, { customExtensions: unreadable })
+ ).toEqual([]);
+ });
+
it("reads the certificate back when there is no request behind it, for imports and discovery", () => {
expect(
resolveRenewalCustomExtensions({ exists: false, customExtensions: null }, { customExtensions: [asked] })