|
|
@@ -47,7 +47,7 @@ namespace MQTTnet.Server.Mqtt |
|
|
|
MqttSubscriptionInterceptor mqttSubscriptionInterceptor, |
|
|
|
MqttApplicationMessageInterceptor mqttApplicationMessageInterceptor, |
|
|
|
MqttServerStorage mqttServerStorage, |
|
|
|
PythonScriptHostService pythonScriptHostService, |
|
|
|
PythonScriptHostService pythonScriptHostService, |
|
|
|
ILogger<MqttServerService> logger) |
|
|
|
{ |
|
|
|
_settings = mqttSettings ?? throw new ArgumentNullException(nameof(mqttSettings)); |
|
|
@@ -179,7 +179,7 @@ namespace MQTTnet.Server.Mqtt |
|
|
|
.WithApplicationMessageInterceptor(_mqttApplicationMessageInterceptor) |
|
|
|
.WithSubscriptionInterceptor(_mqttSubscriptionInterceptor) |
|
|
|
.WithStorage(_mqttServerStorage); |
|
|
|
|
|
|
|
|
|
|
|
// Configure unencrypted connections |
|
|
|
if (_settings.TcpEndPoint.Enabled) |
|
|
|
{ |
|
|
@@ -210,9 +210,23 @@ namespace MQTTnet.Server.Mqtt |
|
|
|
{ |
|
|
|
options |
|
|
|
.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)) |
|
|
|
{ |
|
|
|
options.WithEncryptedEndpointBoundIPAddress(address4); |
|
|
|