mirror of
https://gitlab.com/fabinfra/fabaccess/borepin.git
synced 2025-03-12 14:51:44 +01:00
Fixed: TLS Timeout
This commit is contained in:
parent
9c1d979111
commit
2ce8113644
@ -6,6 +6,7 @@ using NLog;
|
|||||||
using S22.Sasl;
|
using S22.Sasl;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
@ -336,27 +337,42 @@ namespace FabAccessAPI
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Injects SSL as Midlayer in TCPRPCConnection
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="ConnectionException"></exception>
|
||||||
|
private Stream InjectSSL(Stream tcpstream)
|
||||||
|
{
|
||||||
|
SslStream sslStream = new SslStream(tcpstream, false, new RemoteCertificateValidationCallback(_RemoteCertificateValidationCallback));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sslStream.ReadTimeout = 2000;
|
||||||
|
sslStream.AuthenticateAsClient("bffhd");
|
||||||
|
sslStream.ReadTimeout = -1;
|
||||||
|
|
||||||
|
return sslStream;
|
||||||
|
}
|
||||||
|
catch (System.Security.Authentication.AuthenticationException exception)
|
||||||
|
{
|
||||||
|
sslStream.Close();
|
||||||
|
Log.Warn(exception);
|
||||||
|
throw new ConnectionException("TLS failed", exception);
|
||||||
|
}
|
||||||
|
catch(IOException exception)
|
||||||
|
{
|
||||||
|
sslStream.Close();
|
||||||
|
Log.Warn(exception);
|
||||||
|
throw new ConnectionException("TLS failed", new Exceptions.TimeoutException("TLS timeout", exception));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Connect async to a server with ConnectionData
|
/// Connect async to a server with ConnectionData
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="ConnectionException">Based on RPC Exception</exception>
|
/// <exception cref="ConnectionException">Based on RPC Exception</exception>
|
||||||
private async Task _ConnectAsync(TcpRpcClient tcprpcClient, ConnectionData connectionData)
|
private async Task _ConnectAsync(TcpRpcClient tcprpcClient, ConnectionData connectionData)
|
||||||
{
|
{
|
||||||
tcprpcClient.InjectMidlayer((tcpstream) =>
|
tcprpcClient.InjectMidlayer(InjectSSL);
|
||||||
{
|
|
||||||
var sslStream = new SslStream(tcpstream, false, new RemoteCertificateValidationCallback(_RemoteCertificateValidationCallback));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
sslStream.AuthenticateAsClient("bffhd");
|
|
||||||
return sslStream;
|
|
||||||
}
|
|
||||||
catch (System.Security.Authentication.AuthenticationException exception)
|
|
||||||
{
|
|
||||||
sslStream.Close();
|
|
||||||
Log.Warn(exception);
|
|
||||||
throw new ConnectionException("TLS failed", exception);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user