Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Tcp.NET.Client/Handlers/TcpClientHandlerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ protected virtual async Task CreateSSLConnectionAsync(CancellationToken cancella

await sslStream.AuthenticateAsClientAsync(new SslClientAuthenticationOptions
{
TargetHost = _parameters.Host
TargetHost = _parameters.Host,
ClientCertificates = _parameters.ClientCertificates,
}, cancellationToken).ConfigureAwait(false);

if (sslStream.IsAuthenticated && sslStream.IsEncrypted && !cancellationToken.IsCancellationRequested)
Expand Down
2 changes: 2 additions & 0 deletions Tcp.NET.Client/Models/IParamsTcpClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using PHS.Networking.Models;
using System.Security.Cryptography.X509Certificates;

namespace Tcp.NET.Client.Models
{
Expand All @@ -15,5 +16,6 @@ public interface IParamsTcpClient : IParams
byte[] Token { get; }
bool UseDisconnectBytes { get; }
bool UsePingPong { get; }
X509CertificateCollection ClientCertificates { get; }
}
}
5 changes: 4 additions & 1 deletion Tcp.NET.Client/Models/ParamsTcpClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using PHS.Networking.Utilities;
using System;
using System.Security.Cryptography.X509Certificates;
using System.Text;

namespace Tcp.NET.Client.Models
Expand All @@ -17,8 +18,9 @@ public class ParamsTcpClient : IParamsTcpClient
public byte[] Token { get; protected set; }
public bool UseDisconnectBytes { get; protected set; }
public byte[] DisconnectBytes { get; protected set; }
public X509CertificateCollection ClientCertificates { get; protected set; }

public ParamsTcpClient(string host, int port, string endOfLineCharacters, string token = "", bool isSSL = true, bool onlyEmitBytes = false, bool usePingPong = true, string pingCharacters = "ping", string pongCharacters = "pong", bool useDisconnectBytes = true, byte[] disconnectBytes = null)
public ParamsTcpClient(string host, int port, string endOfLineCharacters, string token = "", bool isSSL = true, bool onlyEmitBytes = false, bool usePingPong = true, string pingCharacters = "ping", string pongCharacters = "pong", bool useDisconnectBytes = true, byte[] disconnectBytes = null, X509CertificateCollection clientCertificates = null)
{
if (string.IsNullOrWhiteSpace(host))
{
Expand Down Expand Up @@ -55,6 +57,7 @@ public ParamsTcpClient(string host, int port, string endOfLineCharacters, string
OnlyEmitBytes = onlyEmitBytes;
UseDisconnectBytes = useDisconnectBytes;
DisconnectBytes = disconnectBytes;
ClientCertificates = clientCertificates;

if (!string.IsNullOrWhiteSpace(token))
{
Expand Down
5 changes: 4 additions & 1 deletion Tcp.NET.Client/Models/ParamsTcpClientBytes.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using PHS.Networking.Utilities;
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;

namespace Tcp.NET.Client.Models
Expand All @@ -18,8 +19,9 @@ public class ParamsTcpClientBytes : IParamsTcpClient
public byte[] Token { get; protected set; }
public bool UseDisconnectBytes { get; protected set; }
public byte[] DisconnectBytes { get; protected set; }
public X509CertificateCollection ClientCertificates { get; protected set; }

public ParamsTcpClientBytes(string host, int port, byte[] endOfLineBytes, byte[] token = null, bool isSSL = true, bool onlyEmitBytes = false, bool usePingPong = true, byte[] pingBytes = null, byte[] pongBytes = null, bool useDisconnectBytes = true, byte[] disconnectBytes = null)
public ParamsTcpClientBytes(string host, int port, byte[] endOfLineBytes, byte[] token = null, bool isSSL = true, bool onlyEmitBytes = false, bool usePingPong = true, byte[] pingBytes = null, byte[] pongBytes = null, bool useDisconnectBytes = true, byte[] disconnectBytes = null, X509CertificateCollection clientCertificates = null)
{
if (string.IsNullOrWhiteSpace(host))
{
Expand Down Expand Up @@ -62,6 +64,7 @@ public ParamsTcpClientBytes(string host, int port, byte[] endOfLineBytes, byte[]
UseDisconnectBytes = useDisconnectBytes;
DisconnectBytes = disconnectBytes;
Token = token;
ClientCertificates = clientCertificates;

if (UseDisconnectBytes && (DisconnectBytes == null || Statics.ByteArrayEquals(DisconnectBytes, Array.Empty<byte>())))
{
Expand Down