Exemple #1
0
        private void InitializeSensorsClient(string sensorsUrl, X509Certificate2 clientCertificate)
        {
            HttpClientHandler handler = new HttpClientHandler();

            handler.ClientCertificateOptions = ClientCertificateOption.Manual;
            handler.ClientCertificates.Add(new X509Certificate2(clientCertificate));
            handler.SslProtocols      = SslProtocols.Tls13 | SslProtocols.Tls12;
            handler.AllowAutoRedirect = true;
            handler.ServerCertificateCustomValidationCallback = ServerCertificateValidationCallback;

            var channel = GrpcChannel.ForAddress(sensorsUrl, new GrpcChannelOptions()
            {
                HttpHandler = handler,
            });

            _sensorsClient = new Sensors.SensorsClient(channel);
        }
        private void InitializeSensorsClient(string sensorsUrl, X509Certificate2 clientCertificate)
        {
            if (_channel != null)
            {
                _channel.ShutdownAsync();
                _channel.Dispose();
                _channel = null;
            }

            var handler = CreateHandler(sensorsUrl, clientCertificate);

            _channel = GrpcChannel.ForAddress(sensorsUrl, new GrpcChannelOptions()
            {
                HttpHandler           = handler,
                MaxReceiveMessageSize = 40 * 1024 * 1024,
                MaxSendMessageSize    = 40 * 1024 * 1024,
            });

            _sensorsClient = new Sensors.SensorsClient(_channel);
        }