Montag, 3. Mai 2010

Webservice certificate invalid

Ich hatte folgendes Problem. Beim Aufrufen eines Webservice, bekam ich folgenden Error:
The remote certificate is invalid according to the validation procedure
Dieser besagt, dass das Zertifikat, welches benutzt wird anscheinend nicht gültig ist. Damit man diesen Fehler ignorieren kann, vor dem Aufruf und der Arbeit mit dem Webservice folgenden Code einfügen:
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

// add this to your code before you make your web service call.
System.Net.ServicePointManager.ServerCertificateValidationCallback +=
delegate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors sslError)
{
bool validationResult = true;
return validationResult;
};


I had the following problem. When calling a webservice I received this error:
The remote certificate is invalid according to the validation procedure
This error means, that the certificate of the requested page is not valid. To ignore this error, you have to add the following code, before working and calling with the webservice:
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

// add this to your code before you make your web service call.
System.Net.ServicePointManager.ServerCertificateValidationCallback +=
delegate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors sslError)
{
bool validationResult = true;
return validationResult;
};

Keine Kommentare:

Kommentar veröffentlichen