File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -218,9 +218,11 @@ private bool ValidateServerCertificate(MqttClientCertificateValidationEventArgs
218218 Logger . Info ( $ "Valid From : { serverCertificate . NotBefore } ") ;
219219 Logger . Info ( $ "Valid Until : { serverCertificate . NotAfter } ") ;
220220 Logger . Info ( $ "Key Algorithm : { serverCertificate . GetKeyAlgorithm ( ) } ") ;
221+ string servercertificatePath = this . app . ActiveConfiguration . MqttProviderConfig . ServerCertificatePath ;
222+ string customCertificatePath = this . app . ActiveConfiguration . MqttProviderConfig . CustomCaCertificatePath ;
221223
222224 // Zertifikat speichern, falls nicht vorhanden
223- if ( ! File . Exists ( this . app . ActiveConfiguration . MqttProviderConfig . ServerCertificatePath ) )
225+ if ( servercertificatePath != null && ! File . Exists ( servercertificatePath ) )
224226 {
225227 Logger . Info ( "Saving server certificate to disk." ) ;
226228 File . WriteAllBytes ( this . app . ActiveConfiguration . MqttProviderConfig . ServerCertificatePath , serverCertificate . Export ( X509ContentType . Cert ) ) ;
@@ -251,7 +253,7 @@ private bool ValidateServerCertificate(MqttClientCertificateValidationEventArgs
251253 }
252254
253255 // Schritt 2: Validierung mit benutzerdefinierter CA (falls vorhanden)
254- if ( File . Exists ( this . app . ActiveConfiguration . MqttProviderConfig . CustomCaCertificatePath ) )
256+ if ( customCertificatePath != null && File . Exists ( customCertificatePath ) )
255257 {
256258 var customCaCertificate = new X509Certificate2 ( File . ReadAllBytes ( this . app . ActiveConfiguration . MqttProviderConfig . CustomCaCertificatePath ) ) ;
257259 using var customChain = new X509Chain ( ) ;
You can’t perform that action at this time.
0 commit comments