Merge branch 'master' of https://github.com/chkr1011/MQTTnet into feature/Reason_Code_In_Subscription_Interceptor

# Conflicts:
#	Source/MQTTnet/Server/Internal/MqttClientSessionsManager.cs
This commit is contained in:
Christian
2021-10-23 13:16:57 +02:00
4 changed files with 63 additions and 15 deletions
@@ -19,11 +19,7 @@ namespace MQTTnet.Client.Options
public Func<MqttClientCertificateValidationCallbackContext, bool> CertificateValidationHandler { get; set; }
#if NETCOREAPP3_1 || NET5_0
public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls13;
#else
public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12;
#endif
public SslProtocols SslProtocol { get; set; } = SslProtocols.None;
#if WINDOWS_UWP
public IEnumerable<IEnumerable<byte>> Certificates { get; set; }
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Net.Security;
using System.Security.Authentication;
@@ -26,11 +26,7 @@ namespace MQTTnet.Client.Options
public List<SslApplicationProtocol> ApplicationProtocols { get; set; }
#endif
#if NETCOREAPP3_1 || NET5_0
public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls13;
#else
public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12;
#endif
public SslProtocols SslProtocol { get; set; } = SslProtocols.None;
[Obsolete("This property will be removed soon. Use CertificateValidationHandler instead.")]
public Func<X509Certificate, X509Chain, SslPolicyErrors, IMqttClientOptions, bool> CertificateValidationCallback { get; set; }
@@ -107,9 +107,11 @@ namespace MQTTnet.Server.Internal
return;
}
clientConnection = await CreateClientConnection(connectPacket, channelAdapter, connectionValidatorContext.SessionItems).ConfigureAwait(false);
connAckPacket = _connAckPacketFactory.Create(connectionValidatorContext);
// Pass connAckPacket so that IsSessionPresent flag can be set if the client session already exists
clientConnection = await CreateClientConnection(connectPacket, connAckPacket, channelAdapter, connectionValidatorContext.SessionItems).ConfigureAwait(false);
await channelAdapter.SendPacketAsync(connAckPacket, cancellationToken).ConfigureAwait(false);
await _eventDispatcher.SafeNotifyClientConnectedAsync(connectPacket, channelAdapter).ConfigureAwait(false);
@@ -517,7 +519,8 @@ namespace MQTTnet.Server.Internal
}
async Task<MqttClientConnection> CreateClientConnection(
MqttConnectPacket connectPacket,
MqttConnectPacket connectPacket,
MqttConnAckPacket connAckPacket,
IMqttChannelAdapter channelAdapter,
IDictionary<object, object> sessionItems)
{
@@ -543,6 +546,7 @@ namespace MQTTnet.Server.Internal
else
{
_logger.Verbose("Reusing existing session of client '{0}'.", connectPacket.ClientId);
connAckPacket.IsSessionPresent = true;
}
}