Avatar of lloyd142
lloyd142
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Why can't Java talk to https server?

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

Open in new window

JavaLinux

Avatar of undefined
Last Comment
lloyd142

8/22/2022 - Mon
MicheleMarcon

Did you try with Java 6?
lloyd142

ASKER
No I haven't tried Java 6. Unfortunately upgrading the Java version is not really an option on this server
lloyd142

ASKER
More points available
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
lloyd142

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.