Expose client certificate at MQTT connection validator. Make DualMode optional.

This commit is contained in:
Christian Kratky
2019-06-06 19:31:43 +02:00
parent 2b9b22def6
commit 60c6074953
19 changed files with 116 additions and 30 deletions
@@ -136,7 +136,7 @@ namespace MQTTnet.Server
await connection.StopAsync().ConfigureAwait(false);
}
if (_sessions.TryRemove(clientId, out var session))
if (_sessions.TryRemove(clientId, out _))
{
}
@@ -296,7 +296,8 @@ namespace MQTTnet.Server
connectPacket.Password,
connectPacket.WillMessage,
clientAdapter.Endpoint,
clientAdapter.IsSecureConnection);
clientAdapter.IsSecureConnection,
clientAdapter.ClientCertificate);
var connectionValidator = _options.ConnectionValidator;
@@ -1,4 +1,5 @@
using System.Text;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using MQTTnet.Protocol;
namespace MQTTnet.Server
@@ -11,7 +12,8 @@ namespace MQTTnet.Server
byte[] password,
MqttApplicationMessage willMessage,
string endpoint,
bool isSecureConnection)
bool isSecureConnection,
X509Certificate2 clientCertificate)
{
ClientId = clientId;
Username = username;
@@ -19,6 +21,7 @@ namespace MQTTnet.Server
WillMessage = willMessage;
Endpoint = endpoint;
IsSecureConnection = isSecureConnection;
ClientCertificate = clientCertificate;
}
public string ClientId { get; }
@@ -35,6 +38,8 @@ namespace MQTTnet.Server
public bool IsSecureConnection { get; }
public X509Certificate2 ClientCertificate { get; }
public MqttConnectReturnCode ReturnCode { get; set; } = MqttConnectReturnCode.ConnectionAccepted;
}
}