Skip to content

Commit ad8032d

Browse files
fix
1 parent b14b3f6 commit ad8032d

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

src/Ydb.Sdk/src/Pool/ChannelPool.cs

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -103,38 +103,37 @@ public GrpcChannel CreateChannel(string endpoint)
103103
return GrpcChannel.ForAddress(endpoint, channelOptions);
104104
}
105105

106+
var httpHandler = new SocketsHttpHandler();
107+
106108
var customCertificate = DotNetUtilities.FromX509Certificate(_x509Certificate);
107109

108-
var httpHandler = new HttpClientHandler
109-
{
110-
ServerCertificateCustomValidationCallback =
111-
(_, certificate, _, sslPolicyErrors) =>
110+
httpHandler.SslOptions.RemoteCertificateValidationCallback =
111+
(_, certificate, _, sslPolicyErrors) =>
112+
{
113+
if (sslPolicyErrors == SslPolicyErrors.None)
112114
{
113-
if (sslPolicyErrors == SslPolicyErrors.None)
114-
{
115-
return true;
116-
}
117-
118-
if (certificate is null)
119-
{
120-
return false;
121-
}
122-
123-
try
124-
{
125-
var cert = DotNetUtilities.FromX509Certificate(certificate);
126-
cert.Verify(customCertificate.GetPublicKey());
127-
}
128-
catch (Exception e)
129-
{
130-
_logger.LogError(e, "Failed to verify remote certificate!");
131-
132-
return false;
133-
}
134-
135115
return true;
136116
}
137-
};
117+
118+
if (certificate is null)
119+
{
120+
return false;
121+
}
122+
123+
try
124+
{
125+
var cert = DotNetUtilities.FromX509Certificate(certificate);
126+
cert.Verify(customCertificate.GetPublicKey());
127+
}
128+
catch (Exception e)
129+
{
130+
_logger.LogError(e, "Failed to verify remote certificate!");
131+
132+
return false;
133+
}
134+
135+
return true;
136+
};
138137
httpHandler.Properties["__GrpcLoadBalancingDisabled"] = true;
139138

140139
channelOptions.HttpHandler = httpHandler;

0 commit comments

Comments
 (0)