How to extract the domain name out of an X509Certificate object during SslStream.AuthenticateAsClient? (.NET4)
I have a RemoteCertificateValidationCallback function called by SslStream.AuthenticateAsClient, which is passed an X509Certificate object. I'd like to extract the name from that certificate, such that had I passed that string into AuthenticateAsClient, it would have passed. (Assuming no other issues.) (Note: The Subject property contains the domain name, but it's inside a "CN=..., S=..." etc formatted string.) See also: How to extract CN from X509Certificate in Java? (Asks a similar question for Java, but I can't find similar classes for .NET mentioned in those answers.) (Followup to Eugene's