private string CleanFileName(string fileName)
{
string regexSearch =
new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
Regex r = new Regex(String.Format("[{0}]", Regex.Escape(regexSearch)));
return r.Replace(fileName, "");
}
Friday, August 26, 2011
Thursday, August 18, 2011
The remote certificate is invalid according to the validation procedure
Yesterday during my development, I have to use a web service on https in my C# program. I created my own self signed certificate with IIS 7. I installed it and then bammmm got this error "The remote certificate is invalid according to the validation procedure" while calling the web service.
The solution to fix this problem was a valid certificate for my machine.. but I was not able to create one... so Then I found the solution, that I can override certificate checking using the following code...
ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
bool validationResult = true;
//
// policy code here ...
//
return validationResult
};
The solution to fix this problem was a valid certificate for my machine.. but I was not able to create one... so Then I found the solution, that I can override certificate checking using the following code...
ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
bool validationResult = true;
//
// policy code here ...
//
return validationResult
};
Monday, August 1, 2011
Subscribe to:
Posts (Atom)