@@ -75,17 +75,17 @@ public interface IChannelFactory<out T> where T : ChannelBase, IDisposable
7575
7676internal class GrpcChannelFactory : IChannelFactory < GrpcChannel >
7777{
78+ private const int KeepAlivePingDelaySeconds = 10 ;
79+
7880 private readonly ILoggerFactory _loggerFactory ;
7981 private readonly ILogger < GrpcChannelFactory > _logger ;
80- private readonly DriverConfig _config ;
81-
82- private X509Certificate2Collection ServerCertificates => _config . CustomServerCertificates ;
82+ private readonly X509Certificate2Collection _x509Certificate2Collection ;
8383
8484 internal GrpcChannelFactory ( ILoggerFactory loggerFactory , DriverConfig config )
8585 {
8686 _loggerFactory = loggerFactory ;
8787 _logger = loggerFactory . CreateLogger < GrpcChannelFactory > ( ) ;
88- _config = config ;
88+ _x509Certificate2Collection = config . CustomServerCertificates ;
8989 }
9090
9191 public GrpcChannel CreateChannel ( string endpoint )
@@ -99,7 +99,7 @@ public GrpcChannel CreateChannel(string endpoint)
9999
100100 var httpHandler = new SocketsHttpHandler
101101 {
102- KeepAlivePingDelay = _config . KeepAlivePingDelay
102+ KeepAlivePingDelay = TimeSpan . FromSeconds ( KeepAlivePingDelaySeconds )
103103 } ;
104104
105105 // https://github.com/grpc/grpc-dotnet/issues/2312#issuecomment-1790661801
@@ -108,7 +108,7 @@ public GrpcChannel CreateChannel(string endpoint)
108108 channelOptions . HttpHandler = httpHandler ;
109109 channelOptions . DisposeHttpClient = true ;
110110
111- if ( ServerCertificates . Count == 0 )
111+ if ( _x509Certificate2Collection . Count == 0 )
112112 {
113113 return GrpcChannel . ForAddress ( endpoint , channelOptions ) ;
114114 }
@@ -129,11 +129,11 @@ public GrpcChannel CreateChannel(string endpoint)
129129 try
130130 {
131131 chain . ChainPolicy . VerificationFlags = X509VerificationFlags . AllowUnknownCertificateAuthority ;
132- chain . ChainPolicy . ExtraStore . AddRange ( ServerCertificates ) ;
132+ chain . ChainPolicy . ExtraStore . AddRange ( _x509Certificate2Collection ) ;
133133
134- return chain . Build ( new X509Certificate2 ( certificate ) )
135- && chain . ChainElements . Any ( chainElement => ServerCertificates . Any ( trustedCert =>
136- chainElement . Certificate . Thumbprint == trustedCert . Thumbprint ) ) ;
134+ return chain . Build ( new X509Certificate2 ( certificate ) ) && chain . ChainElements . Any ( chainElement =>
135+ _x509Certificate2Collection . Any ( trustedCert =>
136+ chainElement . Certificate . Thumbprint == trustedCert . Thumbprint ) ) ;
137137 }
138138 catch ( Exception e )
139139 {
0 commit comments