title: Call WebService from C# application using SSL
body: <p>In my C# desktop application, I am calling web services developed in php. I can have the CA file. I don't know how to call the web service via SSL and authenticating the certificate. What do I have to pass the server and what to expect in response form the server for authenticating ? Honestly I have no idea. </p>
  
  <p>EDIT :
  Referred from : <a href="http://weblogs.asp.net/jan/archive/2003/12/04/41154.aspx" rel="nofollow">http://weblogs.asp.net/jan/archive/2003/12/04/41154.aspx</a></p>
  
  <p>// Before calling web service
      System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();</p>
  
  <pre><code>public class MyPolicy : ICertificatePolicy
  {
      X509Certificate clientCert = null;
  
      public MyPolicy() {
          clientCert = X509Certificate.CreateFromSignedFile(HTTPUtility.CERT_FILE);
      }
  
      public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
      {
          Console.WriteLine("********* Into CheckValidationResult : " + certificate.ToString());
  
          Console.WriteLine("####### Client Certificate : " + clientCert.ToString() + "\n" + "Subject = " + clientCert.Subject);
          Console.WriteLine("Issuer : " + clientCert.Issuer + "\n Seral No : " + clientCert.GetSerialNumberString());
          Console.WriteLine("Not Before : " + clientCert.GetEffectiveDateString() +" \n Not After : " + clientCert.GetExpirationDateString());
          Console.WriteLine("Thumb Print : " + clientCert.GetPublicKeyString());
          Console.WriteLine("######## EQuals SERVER CERT : " + clientCert.Equals(certificate));
  
          // Force to return true
          return true;
      }
  }
  </code></pre>
  
  <p>Is the above method of checking correct ? If not why and what can be the solution. I also get this warning "'System.Net.ServicePointManager.CertificatePolicy' is obsolete: 'CertificatePolicy is obsoleted for this type, please use ServerCertificateValidationCallback instead.".</p>
  
  <p>With this how can I know if the CheckValidationResult() returned false ?</p>
  
  <p>Any help is highly appreciated. </p>
  
  <p>Thanks</p>