views:

638

answers:

1

Hello everyone,

I want to use https to upload a file using WebClient's UploadData method. And I want to ignore server side certificate verification (always accept server certificate and only use encryption feature of https).

I have tried hard but cannot find a similar sample. Could anyone advise me how to implement? Any reference samples?

I am using VSTS2008 + C# + .Net 3.5. Target server is running with IIS 7.0 + Windows Vista x64.

thanks in advance, George

+4  A: 

Try adding this before you send you HTTPS requests (make sure you import System.Net namespace).

ServicePointManager.ServerCertificateValidationCallback += 
    delegate(object sender, X509Certificate certificate, X509Chain chain, 
    SslPolicyErrors sslPolicyErrors)
{
   return true;
};
RaYell
Thanks, your method works!
George2