I have recently been working on a C# application that calls a webservice over SSL and handles the certificate security using a delegate for the ServerCertificateValidationCallback event like so:
System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object certsender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
bool validationResult = false;
// if there are no SSL validation errors
if (sslPolicyErrors == SslPolicyErrors.None)
{
validationResult = true;
}
return validationResult;
};
Now I need to do the same thing in Java and this is where I'm stuck - I've googled for a while and not really found a straight-forward answer. How do I handle SSL certificate validation in Java?