I helped my colleagues see a problem with accessing the remote WebService with a certificate. It has never been successful.
Use a browser to access, select a certificate, and ignore some issues. Code Wse2.0 is also installed, and x509certificate is also specified correctly (the original certificate may not have to be imported to the certificate library, but can be directly specified by path ),
However, the Code throws webexception-authenticationexception. The message in the verification exception is: the remote certificate is invalid. Check whether soaphttpclientprotocol has other certificate-related settings. If you haven't found the settings for a while, you can't do it. Please ask Google and enter "WebService, the remote certificate is invalid,
This web page helped: http://www.xue163.com/html/2008625/631589.html
Add this sentence in 2.0:
Servicepointmanager. servercertificatevalidationcallback = new system. net. Security. remotecertificatevalidationcallback (checkvalidationresult );
Public bool checkvalidationresult (Object sender, x509certificate certificate, x509chain chain, sslpolicyerrors errors)
{
// No matter what the server certificate is, it passes the verification.
Return true;
}
Add the above processing and try again. The operation is successful.
To verify whether the remote certificate is captured in the callback of checkvalidationresult, I recorded the logs in this callback function:
Public bool checkvalidationresult (Object sender, x509certificate certificate, x509chain chain, sslpolicyerrors errors)
{
Logger. Info (errors. tostring ());
// No matter what the server certificate is, it passes the verification.
Return true;
}
Well, the error message is displayed. Remote Certificate Name Mismatch.
This error message is the same as the problem that occurs in the browser, but the problem can be ignored in the browser and "continue" constantly. In the C # code, it was originally through servicepointmanager. servercertificatevalidationcallback adds a callback to provide verification.