mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-22 04:43:04 +08:00
Expose client certificate at MQTT connection validator. Make DualMode optional.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user