mirror of https://github.com/grpc/grpc-node.git
Merge pull request #2956 from murgatroid99/grpc-js_sni_fix
grpc-js: Fix ability to set SNI with ssl_target_name_override option
This commit is contained in:
commit
7729fb7d89
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@grpc/grpc-js",
|
"name": "@grpc/grpc-js",
|
||||||
"version": "1.13.3",
|
"version": "1.13.4",
|
||||||
"description": "gRPC Library for Node - pure JS implementation",
|
"description": "gRPC Library for Node - pure JS implementation",
|
||||||
"homepage": "https://grpc.io/",
|
"homepage": "https://grpc.io/",
|
||||||
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
||||||
|
|
|
@ -206,6 +206,18 @@ function getConnectionOptions(secureContext: SecureContext, verifyOptions: Verif
|
||||||
const connectionOptions: ConnectionOptions = {
|
const connectionOptions: ConnectionOptions = {
|
||||||
secureContext: secureContext
|
secureContext: secureContext
|
||||||
};
|
};
|
||||||
|
let realTarget: GrpcUri = channelTarget;
|
||||||
|
if ('grpc.http_connect_target' in options) {
|
||||||
|
const parsedTarget = parseUri(options['grpc.http_connect_target']!);
|
||||||
|
if (parsedTarget) {
|
||||||
|
realTarget = parsedTarget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const targetPath = getDefaultAuthority(realTarget);
|
||||||
|
const hostPort = splitHostPort(targetPath);
|
||||||
|
const remoteHost = hostPort?.host ?? targetPath;
|
||||||
|
connectionOptions.host = remoteHost;
|
||||||
|
|
||||||
if (verifyOptions.checkServerIdentity) {
|
if (verifyOptions.checkServerIdentity) {
|
||||||
connectionOptions.checkServerIdentity = verifyOptions.checkServerIdentity;
|
connectionOptions.checkServerIdentity = verifyOptions.checkServerIdentity;
|
||||||
}
|
}
|
||||||
|
@ -225,36 +237,11 @@ function getConnectionOptions(secureContext: SecureContext, verifyOptions: Verif
|
||||||
};
|
};
|
||||||
connectionOptions.servername = sslTargetNameOverride;
|
connectionOptions.servername = sslTargetNameOverride;
|
||||||
} else {
|
} else {
|
||||||
if ('grpc.http_connect_target' in options) {
|
connectionOptions.servername = remoteHost;
|
||||||
/* This is more or less how servername will be set in createSession
|
|
||||||
* if a connection is successfully established through the proxy.
|
|
||||||
* If the proxy is not used, these connectionOptions are discarded
|
|
||||||
* anyway */
|
|
||||||
const targetPath = getDefaultAuthority(
|
|
||||||
parseUri(options['grpc.http_connect_target'] as string) ?? {
|
|
||||||
path: 'localhost',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const hostPort = splitHostPort(targetPath);
|
|
||||||
connectionOptions.servername = hostPort?.host ?? targetPath;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (options['grpc-node.tls_enable_trace']) {
|
if (options['grpc-node.tls_enable_trace']) {
|
||||||
connectionOptions.enableTrace = true;
|
connectionOptions.enableTrace = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let realTarget: GrpcUri = channelTarget;
|
|
||||||
if ('grpc.http_connect_target' in options) {
|
|
||||||
const parsedTarget = parseUri(options['grpc.http_connect_target']!);
|
|
||||||
if (parsedTarget) {
|
|
||||||
realTarget = parsedTarget;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const targetPath = getDefaultAuthority(realTarget);
|
|
||||||
const hostPort = splitHostPort(targetPath);
|
|
||||||
const remoteHost = hostPort?.host ?? targetPath;
|
|
||||||
connectionOptions.host = remoteHost;
|
|
||||||
connectionOptions.servername = remoteHost;
|
|
||||||
return connectionOptions;
|
return connectionOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue