I have a client server setup. The client creates a proxy to communicate with the server. When the communication protocol is HTTPS, the proxy listens for the SSL certificate verification event on the following line:
ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate);
The ValidateRemoteCertificate method refers to certificate exceptions.
In the client, the user can choose one of 3 security levels: low, medium and high. At a low level, the ValidateRemoteCertificate method ignores any errors and always returns true. At a middle level, the ValidateRemoteCertificate method fires an event that notifies the client of the problem. At this point, a message appears to the user informing him that the certificate is problematic and allows the user to choose whether to continue or accept the connection to the server or to decline. At a high level, the ValidateRemoteCertificate method rejects the connection for any error.
So far so good.
The scenario is as follows:
- The client boots up with the Medium predefined security level that has already been accepted by the user, and the connection is established with the server without spreading any certificate problems.
- The user disconnects the client from the server (using a special button).
- The user is trying to reconnect the client. At this stage, the client has the opportunity to test the connection using the test button. The test method returns success, although a new proxy was created for the connection test, and all ValidateRemoteCertificate methods were removed from ServerCertificateValidationCallback (a specific type of proxy). In addition, no event is fired for the problem certificate, and the ValidateRemoteCertificate method is not called.
The behavior I'm trying to achieve is that when the test runs, ServerCertificateValidationCallback will behave as if it was the first to call it after the client starts, and ValidateRemoteCertificate will come into play.
I tried looking for any method that clears any delegates / events in ServicePointManager, but I could not find them.
Is there any cache that can be cleared? I hope the scenario is clear enough.
c # certificate ssl
owyn
source share