|
@@ -47,7 +47,7 @@ namespace MQTTnet.Server.Mqtt |
|
|
MqttSubscriptionInterceptor mqttSubscriptionInterceptor, |
|
|
MqttSubscriptionInterceptor mqttSubscriptionInterceptor, |
|
|
MqttApplicationMessageInterceptor mqttApplicationMessageInterceptor, |
|
|
MqttApplicationMessageInterceptor mqttApplicationMessageInterceptor, |
|
|
MqttServerStorage mqttServerStorage, |
|
|
MqttServerStorage mqttServerStorage, |
|
|
PythonScriptHostService pythonScriptHostService, |
|
|
|
|
|
|
|
|
PythonScriptHostService pythonScriptHostService, |
|
|
ILogger<MqttServerService> logger) |
|
|
ILogger<MqttServerService> logger) |
|
|
{ |
|
|
{ |
|
|
_settings = mqttSettings ?? throw new ArgumentNullException(nameof(mqttSettings)); |
|
|
_settings = mqttSettings ?? throw new ArgumentNullException(nameof(mqttSettings)); |
|
@@ -179,7 +179,7 @@ namespace MQTTnet.Server.Mqtt |
|
|
.WithApplicationMessageInterceptor(_mqttApplicationMessageInterceptor) |
|
|
.WithApplicationMessageInterceptor(_mqttApplicationMessageInterceptor) |
|
|
.WithSubscriptionInterceptor(_mqttSubscriptionInterceptor) |
|
|
.WithSubscriptionInterceptor(_mqttSubscriptionInterceptor) |
|
|
.WithStorage(_mqttServerStorage); |
|
|
.WithStorage(_mqttServerStorage); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Configure unencrypted connections |
|
|
// Configure unencrypted connections |
|
|
if (_settings.TcpEndPoint.Enabled) |
|
|
if (_settings.TcpEndPoint.Enabled) |
|
|
{ |
|
|
{ |
|
@@ -210,9 +210,23 @@ namespace MQTTnet.Server.Mqtt |
|
|
{ |
|
|
{ |
|
|
options |
|
|
options |
|
|
.WithEncryptedEndpoint() |
|
|
.WithEncryptedEndpoint() |
|
|
.WithEncryptionSslProtocol(SslProtocols.Tls12) |
|
|
|
|
|
.WithEncryptionCertificate(_settings.EncryptedTcpEndPoint.ReadCertificate()); |
|
|
|
|
|
|
|
|
.WithEncryptionSslProtocol(SslProtocols.Tls12); |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_settings.EncryptedTcpEndPoint?.Certificate?.Path)) |
|
|
|
|
|
{ |
|
|
|
|
|
IMqttServerCertificateCredentials certificateCredentials = null; |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_settings.EncryptedTcpEndPoint?.Certificate?.Password)) |
|
|
|
|
|
{ |
|
|
|
|
|
certificateCredentials = new MqttServerCertificateCredentials |
|
|
|
|
|
{ |
|
|
|
|
|
Password = _settings.EncryptedTcpEndPoint.Certificate.Password |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
options.WithEncryptionCertificate(_settings.EncryptedTcpEndPoint.Certificate.ReadCertificate(), certificateCredentials); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (_settings.EncryptedTcpEndPoint.TryReadIPv4(out var address4)) |
|
|
if (_settings.EncryptedTcpEndPoint.TryReadIPv4(out var address4)) |
|
|
{ |
|
|
{ |
|
|
options.WithEncryptedEndpointBoundIPAddress(address4); |
|
|
options.WithEncryptedEndpointBoundIPAddress(address4); |
|
|