I am working on a project that uses some HTTP communication between two server servers. Servers use X509 certificates for authentication. Needless to say, when server A (client) establishes a connection with server B (server), there is an SSL / TLS check error, because the certificates used do not belong to trusted third parties.
Usually the way to handle it is ServicePointManager.ServerCertificateValidationCallback , for example:
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, error) => { return cert.GetCertHashString() == "xxxxxxxxxxxxxxxx"; };
This approach works, except that it is not perfect. In essence, this is a validation override procedure for EVERY HTTP request that an application executes. Thus, if another class tries to start an HTTP request, it will fail. Also, if another class overrides ServicePointManager.ServerCertificateValidationCallback for its own purposes, then my message starts to fail suddenly.
The only solution that comes to mind is creating a separate AppDomain to execute client HTTP requests. This will work, but itβs really stupid to do this just to make HTTP requests possible. The overhead will be overwhelming.
With this in mind, did anyone investigate whether there is a better practice in .NET that would allow access to web services when processing SSL / TLS client checks without affecting other web clients?
galets Jan 03 '14 at 23:04 2014-01-03 23:04
source share