I wanted to call ssl web service. I have server certificate that i installed in trusted store. I am using SOAP UI tool and soap sonar to call ssl web service i am using with htts call to the service.
Looks like certificate is not going through the request.
I have create a C# application to pass the request with certificate.
But still the same error.
Can you suggest any other tools to test webservice ? or sample code?
private void button4_Click(object sender, EventArgs e)
{
try
{
var clientHandler = new WebRequestHandler();
string address = @"https://xxx.xxx.xxx.xxx:58444/IVR/";
var requestXML = "\\request.xml";
var serialized = File.ReadAllText(Environment.CurrentDirectory + requestXML);
var cert = GetCert();
CertificateWebClient myWebClient = new CertificateWebClient(cert);
string fileName = Environment.CurrentDirectory + requestXML;
myWebClient.Headers.Add("Content-Type", "application/xml;charset=utf-8");
byte[] responseArray = myWebClient.UploadFile(address, fileName);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public class CertificateWebClient : WebClient
{
private readonly X509Certificate2 certificate;
public CertificateWebClient(X509Certificate2 cert)
{
certificate = cert;
}
protected override WebRequest GetWebRequest(Uri address)
{
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
request.ServicePoint.Expect100Continue = true;
request.ServerCertificateValidationCallback =
delegate(Object obj,
X509Certificate X509certificate,
X509Chain chain,
System.Net.Security.SslPolicyErrors errors)
{
if (errors == System.Net.Security.SslPolicyErrors.RemoteCertificateNameMismatch)
{
return true;
}
else
{
return false;
}
};
request.ClientCertificates.Add(certificate);
return request;
}
}
Exceptions:-
The request was aborted: Could not create SSL/TLS secure channel.