From 2ce811364402e39e9431c06cb71b20d347a2e103 Mon Sep 17 00:00:00 2001 From: TheJoKlLa Date: Tue, 31 Jan 2023 14:14:33 +0100 Subject: [PATCH 1/5] Fixed: TLS Timeout --- FabAccessAPI/API.cs | 48 ++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/FabAccessAPI/API.cs b/FabAccessAPI/API.cs index 3c81f40..04494cd 100644 --- a/FabAccessAPI/API.cs +++ b/FabAccessAPI/API.cs @@ -6,6 +6,7 @@ using NLog; using S22.Sasl; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Net.Security; using System.Security.Cryptography.X509Certificates; @@ -336,28 +337,43 @@ namespace FabAccessAPI return true; } + /// + /// Injects SSL as Midlayer in TCPRPCConnection + /// + /// + 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)); + } + } + /// /// Connect async to a server with ConnectionData /// /// Based on RPC Exception private async Task _ConnectAsync(TcpRpcClient tcprpcClient, ConnectionData connectionData) { - tcprpcClient.InjectMidlayer((tcpstream) => - { - 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); - } - }); - + tcprpcClient.InjectMidlayer(InjectSSL); + try { Task timeoutTask = Task.Delay(3000); From 1e2604486cf1e675f4520d76d7370efb2c19cc9f Mon Sep 17 00:00:00 2001 From: TheJoKlLa Date: Tue, 31 Jan 2023 15:11:43 +0100 Subject: [PATCH 2/5] Updated QR-Code Scanning --- Borepin/Borepin/Dialog/ScanDialog.xaml | 13 -- Borepin/Borepin/Dialog/ScanDialog.xaml.cs | 20 ---- .../Borepin/DialogModel/ScanDialogModel.cs | 111 ------------------ Borepin/Borepin/Page/ScanPage.xaml | 10 +- Borepin/Borepin/Page/ScanURNPage.xaml | 10 +- 5 files changed, 18 insertions(+), 146 deletions(-) delete mode 100644 Borepin/Borepin/Dialog/ScanDialog.xaml delete mode 100644 Borepin/Borepin/Dialog/ScanDialog.xaml.cs delete mode 100644 Borepin/Borepin/DialogModel/ScanDialogModel.cs diff --git a/Borepin/Borepin/Dialog/ScanDialog.xaml b/Borepin/Borepin/Dialog/ScanDialog.xaml deleted file mode 100644 index ff01a42..0000000 --- a/Borepin/Borepin/Dialog/ScanDialog.xaml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - -