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.
EDIT : Referred from : http://weblogs.asp.net/jan/archive/2003/12/04/41154.aspx
// Before calling web service System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();
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;
}
}
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.".
With this how can I know if the CheckValidationResult() returned false ?
Any help is highly appreciated.
Thanks