public TClientTransport CreateTransport() { if (url == null) { // endpoint transport TClientTransport trans = null; if (pipe != null) { trans = new TNamedPipeClientTransport(pipe); } else { if (encrypted) { var cert = GetClientCert(); if (cert == null || !cert.HasPrivateKey) { throw new InvalidOperationException("Certificate doesn't contain private key"); } trans = new TTlsSocketClientTransport(host, port, 0, cert, (sender, certificate, chain, errors) => true, null, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12); } else { trans = new TSocketClientTransport(host, port); } } // layered transport if (buffered) { trans = new TBufferedClientTransport(trans); } if (framed) { trans = new TFramedClientTransport(trans); } return(trans); } return(new THttpClientTransport(new Uri(url), null)); }
protected override async Task <TClientTransport> AcceptImplementationAsync(CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { return(await Task.FromCanceled <TClientTransport>(cancellationToken)); } if (_server == null) { throw new TTransportException(TTransportException.ExceptionType.NotOpen, "No underlying server socket."); } try { var client = await _server.AcceptTcpClientAsync(); client.SendTimeout = client.ReceiveTimeout = _clientTimeout; //wrap the client in an SSL Socket passing in the SSL cert var tTlsSocket = new TTlsSocketClientTransport(client, _serverCertificate, true, _clientCertValidator, _localCertificateSelectionCallback, _sslProtocols); await tTlsSocket.SetupTlsAsync(); TClientTransport trans = tTlsSocket; if (_useBufferedSockets) { trans = new TBufferedClientTransport(trans); } if (_useFramedTransport) { trans = new TFramedClientTransport(trans); } return(trans); } catch (Exception ex) { throw new TTransportException(ex.ToString()); } }
public TClientTransport CreateTransport() { if (url == null) { // endpoint transport TClientTransport trans = null; if (pipe != null) { trans = new TNamedPipeClientTransport(pipe); } else { if (encrypted) { var certPath = "../../keys/client.p12"; var cert = new X509Certificate2(certPath, "thrift"); trans = new TTlsSocketClientTransport(host, port, 0, cert, (o, c, chain, errors) => true, null, SslProtocols.Tls); } else { trans = new TSocketClientTransport(host, port); } } // layered transport if (buffered) { trans = new TBufferedClientTransport(trans); } if (framed) { trans = new TFramedClientTransport(trans); } return(trans); } return(new THttpClientTransport(new Uri(url), null)); }