Reputation: 5451
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?
Upvotes: 1
Views: 5717
Reputation: 9058
Apache HTTPClient is the best way to handle anything more than a simple get on a URL. Here is the SSL Guide.
Upvotes: 1
Reputation: 5642
Recent java version do it for you. Just point to an HTTPS URL (https://)
Upvotes: 1