1616namespace HiveMQtt . Client . Transport ;
1717
1818using System . IO . Pipelines ;
19+ using System . Globalization ;
20+ using System . Linq ;
1921using System . Net ;
2022using System . Net . Security ;
2123using System . Net . Sockets ;
@@ -78,10 +80,8 @@ internal static bool ValidateServerCertificate(
7880 X509Chain ? chain ,
7981 SslPolicyErrors sslPolicyErrors )
8082 {
81- // Ignore the unused parameters
83+ // Ignore the sender parameter
8284 _ = sender ;
83- _ = certificate ;
84- _ = chain ;
8585
8686 if ( sslPolicyErrors == SslPolicyErrors . None )
8787 {
@@ -90,6 +90,21 @@ internal static bool ValidateServerCertificate(
9090
9191 Logger . Warn ( "Broker TLS Certificate error: {0}" , sslPolicyErrors ) ;
9292
93+ // Log additional certificate details for debugging
94+ if ( certificate != null )
95+ {
96+ Logger . Debug ( CultureInfo . InvariantCulture , "Certificate Subject: {0}" , certificate . Subject ) ;
97+ Logger . Debug ( CultureInfo . InvariantCulture , "Certificate Issuer: {0}" , certificate . Issuer ) ;
98+ Logger . Debug ( CultureInfo . InvariantCulture , "Certificate Serial Number: {0}" , certificate . GetSerialNumberString ( ) ) ;
99+ }
100+
101+ // Validate certificate chain if provided
102+ if ( chain != null )
103+ {
104+ var chainStatus = chain . ChainStatus . Length > 0 ? string . Join ( ", " , chain . ChainStatus . Select ( cs => cs . Status ) ) : "Valid" ;
105+ Logger . Debug ( CultureInfo . InvariantCulture , "Certificate chain validation status: {0}" , chainStatus ) ;
106+ }
107+
93108 // Do not allow this client to communicate with unauthenticated servers.
94109 return false ;
95110 }
0 commit comments