|
@@ -70,15 +70,17 @@ namespace MQTTnet.Implementations |
|
|
#endif |
|
|
#endif |
|
|
clientSocket.NoDelay = true; |
|
|
clientSocket.NoDelay = true; |
|
|
|
|
|
|
|
|
|
|
|
SslStream sslStream = null; |
|
|
|
|
|
|
|
|
if (_tlsCertificate != null) |
|
|
if (_tlsCertificate != null) |
|
|
{ |
|
|
{ |
|
|
var sslStream = new SslStream(new NetworkStream(clientSocket), false); |
|
|
|
|
|
|
|
|
sslStream = new SslStream(new NetworkStream(clientSocket), false); |
|
|
await sslStream.AuthenticateAsServerAsync(_tlsCertificate, false, SslProtocols.Tls12, false).ConfigureAwait(false); |
|
|
await sslStream.AuthenticateAsServerAsync(_tlsCertificate, false, SslProtocols.Tls12, false).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_logger.Verbose($"Client '{clientSocket.RemoteEndPoint}' accepted by TCP listener '{_socket.LocalEndPoint}, {_addressFamily}'."); |
|
|
_logger.Verbose($"Client '{clientSocket.RemoteEndPoint}' accepted by TCP listener '{_socket.LocalEndPoint}, {_addressFamily}'."); |
|
|
|
|
|
|
|
|
var clientAdapter = new MqttChannelAdapter(new MqttTcpChannel(clientSocket, null), new MqttPacketSerializer(), _logger); |
|
|
|
|
|
|
|
|
var clientAdapter = new MqttChannelAdapter(new MqttTcpChannel(clientSocket, sslStream), new MqttPacketSerializer(), _logger); |
|
|
ClientAccepted?.Invoke(this, new MqttServerAdapterClientAcceptedEventArgs(clientAdapter)); |
|
|
ClientAccepted?.Invoke(this, new MqttServerAdapterClientAcceptedEventArgs(clientAdapter)); |
|
|
} |
|
|
} |
|
|
catch (ObjectDisposedException) |
|
|
catch (ObjectDisposedException) |
|
|