Skip to content

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

fix(gateways): pass an IP literal as host instead of SNI

bernie-gf49a7892b217
diff --git a/backend/src/lib/gateway-v2/gateway-v2.ts b/backend/src/lib/gateway-v2/gateway-v2.ts
index d001ce755b..dbe3ce7e59 100644
--- a/backend/src/lib/gateway-v2/gateway-v2.ts
+++ b/backend/src/lib/gateway-v2/gateway-v2.ts
@@ -155,6 +155,9 @@ export const createGatewayConnection = async (
[GatewayProxyProtocol.WinRm]: ["infisical-winrm"]
};
+ // SNI cannot carry an IP literal (RFC 6066), so an address goes in host and a name in servername.
+ const isIpLiteral = Boolean(net.isIP(serverName));
+
const tlsOptions: tls.ConnectionOptions = {
socket: relayConn,
cert: gateway.clientCertificate,
@@ -163,7 +166,8 @@ export const createGatewayConnection = async (
minVersion: "TLSv1.2",
maxVersion: "TLSv1.3",
rejectUnauthorized: true,
- servername: serverName,
+ host: isIpLiteral ? serverName : undefined,
+ servername: isIpLiteral ? undefined : serverName,
ALPNProtocols: protocolToAlpn[protocol],
checkServerIdentity: appCfg.isDevelopmentMode ? () => undefined : tls.checkServerIdentity
};