From bd7d63736a768e2b837351414b6a160062372664 Mon Sep 17 00:00:00 2001 From: EonaCat Date: Wed, 17 Jun 2026 08:29:00 +0200 Subject: [PATCH] Updated to support .net standard 2.0 --- EonaCat.Connections/EonaCat.Connections.csproj | 2 +- EonaCat.Connections/Helpers/AesKeyExchange.cs | 7 +++++++ EonaCat.Connections/NetworkClient.cs | 10 +++++----- EonaCat.Connections/NetworkServer.cs | 2 +- README.md | 3 ++- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/EonaCat.Connections/EonaCat.Connections.csproj b/EonaCat.Connections/EonaCat.Connections.csproj index e02a7ed..f854c45 100644 --- a/EonaCat.Connections/EonaCat.Connections.csproj +++ b/EonaCat.Connections/EonaCat.Connections.csproj @@ -1,7 +1,7 @@  - net48; net8.0 + netstandard2.0; net48; net8.0 latest enable enable diff --git a/EonaCat.Connections/Helpers/AesKeyExchange.cs b/EonaCat.Connections/Helpers/AesKeyExchange.cs index c7f93d2..6b08bc2 100644 --- a/EonaCat.Connections/Helpers/AesKeyExchange.cs +++ b/EonaCat.Connections/Helpers/AesKeyExchange.cs @@ -200,10 +200,17 @@ namespace EonaCat.Connections.Helpers private static byte[] DeriveKey(string password, byte[] salt, int size) { +#if NET472_OR_GREATER || NET8_0_OR_GREATER using (var pbkdf2 = new Rfc2898DeriveBytes(password, salt, _iterations, HashAlgorithmName.SHA256)) { return pbkdf2.GetBytes(size); } +#else + using (var pbkdf2 = new Rfc2898DeriveBytes(password, salt, _iterations)) + { + return pbkdf2.GetBytes(size); + } +#endif } private static byte[] RandomBytes(int total) diff --git a/EonaCat.Connections/NetworkClient.cs b/EonaCat.Connections/NetworkClient.cs index f1e0378..700a08f 100644 --- a/EonaCat.Connections/NetworkClient.cs +++ b/EonaCat.Connections/NetworkClient.cs @@ -541,16 +541,16 @@ namespace EonaCat.Connections sslDiagnostics?.StartStage("ClientAuth"); if (_config.Certificate != null) { - await sslStream.AuthenticateAsClientAsync(_config.Host, new X509CertificateCollection { _config.Certificate }, SslProtocols.Tls12 | SslProtocols.Tls13, _config.CheckCertificateRevocation).ConfigureAwait(false); + await sslStream.AuthenticateAsClientAsync(_config.Host, new X509CertificateCollection { _config.Certificate }, SslProtocols.Tls12, _config.CheckCertificateRevocation).ConfigureAwait(false); } else { - await sslStream.AuthenticateAsClientAsync(_config.Host, null, SslProtocols.Tls12 | SslProtocols.Tls13, _config.CheckCertificateRevocation).ConfigureAwait(false); + await sslStream.AuthenticateAsClientAsync(_config.Host, null, SslProtocols.Tls12, _config.CheckCertificateRevocation).ConfigureAwait(false); } - sslDiagnostics?.EndStage("ClientAuth"); - #endif + sslDiagnostics?.EndStage("ClientAuth"); +#endif - DebugConnection($"SSL authentication successful for {_config.Host}:{_config.Port} using SNI: {_config.Host}, Client Certificate: {(_config.Certificate != null ? "Yes" : "No")}, Enabled Protocols: {(sslStream.SslProtocol)}, Cipher Algorithm: {sslStream.CipherAlgorithm}, Hash Algorithm: {sslStream.HashAlgorithm}, Key Exchange Algorithm: {sslStream.KeyExchangeAlgorithm}"); + DebugConnection($"SSL authentication successful for {_config.Host}:{_config.Port} using SNI: {_config.Host}, Client Certificate: {(_config.Certificate != null ? "Yes" : "No")}, Enabled Protocols: {(sslStream.SslProtocol)}, Cipher Algorithm: {sslStream.CipherAlgorithm}, Hash Algorithm: {sslStream.HashAlgorithm}, Key Exchange Algorithm: {sslStream.KeyExchangeAlgorithm}"); sslDiagnostics?.RecordSuccess(sslStream); if (sslDiagnostics != null) { diff --git a/EonaCat.Connections/NetworkServer.cs b/EonaCat.Connections/NetworkServer.cs index 17f8cdd..cabe07d 100644 --- a/EonaCat.Connections/NetworkServer.cs +++ b/EonaCat.Connections/NetworkServer.cs @@ -831,7 +831,7 @@ namespace EonaCat.Connections DebugConnection($"SSL authentication successful for {remoteEndPoint} on attempt {attempt}."); #else sslDiagnostics?.StartStage("ServerAuth"); - await sslStream.AuthenticateAsServerAsync(_config.Certificate, _config.MutuallyAuthenticate, SslProtocols.Tls12 | SslProtocols.Tls13, _config.CheckCertificateRevocation).ConfigureAwait(false); + await sslStream.AuthenticateAsServerAsync(_config.Certificate, _config.MutuallyAuthenticate, SslProtocols.Tls12, _config.CheckCertificateRevocation).ConfigureAwait(false); sslDiagnostics?.EndStage("ServerAuth"); #endif diff --git a/README.md b/README.md index 6d6ee08..9f688ba 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # EonaCat.Connections -A high-performance, production-ready .NET Framework 4.8+ / .NET 8 compatible library for building scalable TCP/UDP servers and clients with optional TLS encryption and application-layer AES encryption. +A high-performance, production-ready .netStandard 2.0, .NET Framework 4.8+ / .NET 8 compatible library for building scalable TCP/UDP servers and clients with optional TLS encryption and application-layer AES encryption. ## Features @@ -904,6 +904,7 @@ public enum DisconnectReason ## Supported Platforms +- ** .NET Standard 2.0** - Full support - **.NET Framework 4.8+** - Full support - **.NET 8.0** - Full support - **Platforms**: Windows, Linux, macOS (with .NET Core)