Add support for option "tlsAllowInvalidHostnames"

Hello everyone,
at this time, I can only set the option ‘tlsInsecure’ in the c# driver.

Is it planned to implement the ‘tlsAllowInvalidHostnames’ support in the future? Or is a workaround already possible?

Hey @Sven_Terschluse ,

Welcome to the MongoDB Community Forums! We don’t have AllowInvalidHostNames in the .NET/C# Driver because we don’t control TLS negotiation. We delegate to SslStream and call SslStream.AuthenticateAsClient(targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation) . You can implement this yourself by providing a certificate validation callback when constructing the MongoClientSettings like

var settings = new MongoClientSettings {
    SslSettings = new SslSettings { ServerCertificateValidationCallback = customValidator }
};

You can read more about it here. Hope that helps.

Thanks,

Rishit.

Hey @Rishit_Bhatia ,

thank you for your feedback, that helped me a lot.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.