Skip to content

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

fix hdb by passing servername as undefined

Thiago Araujo da Silva011845b3d67b
diff --git a/backend/src/ee/services/dynamic-secret/providers/sap-hana.ts b/backend/src/ee/services/dynamic-secret/providers/sap-hana.ts
index ffb25d53bc..019a010181 100644
--- a/backend/src/ee/services/dynamic-secret/providers/sap-hana.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/sap-hana.ts
@@ -13,6 +13,7 @@ import { TDynamicSecrets } from "@app/db/schemas";
import { BadRequestError } from "@app/lib/errors";
import { sanitizeString } from "@app/lib/fn";
import { validateHandlebarTemplate } from "@app/lib/template/validate-handlebars";
+import { getTlsServerNameOptions } from "@app/lib/tls";
import { ActorIdentityAttributes } from "../../dynamic-secret-lease/dynamic-secret-lease-types";
import { verifyHostInputValidity } from "../dynamic-secret-fns";
@@ -52,7 +53,8 @@ export const SapHanaProvider = (): TDynamicProviderFns => {
...(providerInputs.ca
? {
ca: providerInputs.ca,
- rejectUnauthorized: providerInputs.sslRejectUnauthorized
+ rejectUnauthorized: providerInputs.sslRejectUnauthorized,
+ ...getTlsServerNameOptions(providerInputs.host)
}
: {})
});
diff --git a/backend/src/lib/tls/index.test.ts b/backend/src/lib/tls/index.test.ts
index 25fe56c140..2d54c7d91e 100644
--- a/backend/src/lib/tls/index.test.ts
+++ b/backend/src/lib/tls/index.test.ts
@@ -28,7 +28,8 @@ describe("getTlsServerNameOptions", () => {
test.each(["10.0.0.5", "2001:db8::1", "[2001:db8::1]"])("never sets servername for the IP %s", (host) => {
const options = getTlsServerNameOptions(host);
- expect(options).not.toHaveProperty("servername");
+ // Present but undefined, so a driver that defaults a missing servername to the host leaves it alone.
+ expect(options).toHaveProperty("servername", undefined);
expect(options.checkServerIdentity).toBeTypeOf("function");
});
diff --git a/backend/src/lib/tls/index.ts b/backend/src/lib/tls/index.ts
index c006396553..0c9c61ce6c 100644
--- a/backend/src/lib/tls/index.ts
+++ b/backend/src/lib/tls/index.ts
@@ -8,12 +8,13 @@ export const stripIpv6Brackets = (host: string) =>
// Node 26 throws when servername is an IP (SNI cannot carry one, RFC 6066). Earlier versions still sent the
// IP as SNI, so omitting it changes what the server sees (no SNI, or "localhost" from an https.Agent with no
// Host header). Keep the certificate check against the IP: many callers dial a local gateway proxy, where
-// Node would otherwise verify against "localhost".
+// Node would otherwise verify against "localhost". The servername key stays present for an IP because some
+// drivers (hdb) fill a missing one in from the host, which puts the IP straight back.
export const getTlsServerNameOptions = (
host?: string
): Pick<tls.ConnectionOptions, "servername" | "checkServerIdentity"> => {
if (!host) return { servername: host };
const ip = stripIpv6Brackets(host);
if (!isIP(ip)) return { servername: host };
- return { checkServerIdentity: (_hostname, cert) => tls.checkServerIdentity(ip, cert) };
+ return { servername: undefined, checkServerIdentity: (_hostname, cert) => tls.checkServerIdentity(ip, cert) };
};