From ce05cc9936d464dadf5f022d31090b411879e7cc Mon Sep 17 00:00:00 2001 From: Christian Kratky Date: Sun, 23 Jun 2019 15:39:07 +0200 Subject: [PATCH] Fix MQTTnet.Server connection validation. --- Source/MQTTnet.Server/Mqtt/MqttServerConnectionValidator.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/MQTTnet.Server/Mqtt/MqttServerConnectionValidator.cs b/Source/MQTTnet.Server/Mqtt/MqttServerConnectionValidator.cs index 4e13c83..3b1a2fc 100644 --- a/Source/MQTTnet.Server/Mqtt/MqttServerConnectionValidator.cs +++ b/Source/MQTTnet.Server/Mqtt/MqttServerConnectionValidator.cs @@ -29,10 +29,10 @@ namespace MQTTnet.Server.Mqtt { "client_id", context.ClientId }, { "username", context.Username }, { "password", context.Password }, - { "raw_password", new Bytes(context.RawPassword) }, + { "raw_password", new Bytes(context.RawPassword ?? new byte[0]) }, { "clean_session", context.CleanSession}, { "authentication_method", context.AuthenticationMethod}, - { "authentication_data", new Bytes(context.AuthenticationData)}, + { "authentication_data", new Bytes(context.AuthenticationData ?? new byte[0]) }, { "result", PythonConvert.Pythonfy(context.ReasonCode) } }; @@ -44,6 +44,8 @@ namespace MQTTnet.Server.Mqtt catch (Exception exception) { _logger.LogError(exception, "Error while validating client connection."); + + context.ReasonCode = MqttConnectReasonCode.UnspecifiedError; } return Task.CompletedTask;