troubleshooting Question

Why can't Java talk to https server?

Avatar of lloyd142
lloyd142Flag for United Kingdom of Great Britain and Northern Ireland asked on
LinuxJava
4 Comments1 Solution281 ViewsLast Modified:
HI. I have a Java application that communicates with an https server but recently stopped working. The basis of the code is that it tries to open a URL to https://.... and then spits out this handshaking error:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I understand this looks like a problem with keystores, however the following makes me believe this isn't the case...
1. This same code works on another linux server and a windows machine where no keystore has ever been set up
2. When I replace  the URL in my code with another https URL it works fine without having to setup any keystore
3. I can telnet to and open the URL on the server - it's only Java which fails to communicate with it

It is possible someone in the past has set a keystore on this machine
This isn't the exact code from my application but I have reduced it to this basic statement which gives the same exception:
 
URL url = new URL("https://www.server.co.uk");
System.out.println(url.getContent());
 
I have replaced the actual URL with this dummy one
ASKER CERTIFIED SOLUTION
lloyd142

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros