0

I am trying to find the contents of this page using Java.

https://wordassociations.net/en/words-associated-with/cessation?button=Search

However, I get the error below. How can I resolve it

Exception in thread "main" 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

/*
 * SynonymFinder.java
 * 
 */    
import java.net.URL;
import java.util.Scanner;

public class SynonymFinder {

    public static void main(String[] args) throws Exception {
        SynonymFinder obj = new SynonymFinder();

        System.out.println(get("https://wordassociations.net/en/words-associated-with/cessation?button=Search"));
    }

    public static String get(String url) throws Exception {
        StringBuilder sb = new StringBuilder();
        for(Scanner sc = new Scanner(new URL(url).openStream()); sc.hasNext(); )
           sb.append(sc.nextLine()).append('\n');
        return sb.toString();
     }
}
user121
  • 305
  • 1
  • 3
  • 9
  • Possible duplicate of [PKIX path building failed while making SSL connection](https://stackoverflow.com/questions/2290570/pkix-path-building-failed-while-making-ssl-connection) – KevinO May 23 '17 at 03:56
  • (Also: [Resolving javax.net.ssl.SSLHandshake Exception](https://stackoverflow.com/questions/9619030/resolving-javax-net-ssl-sslhandshakeexception-sun-security-validator-validatore)) – KevinO May 23 '17 at 03:57
  • 1
    Possible duplicates [Resolving javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed Error?](https://stackoverflow.com/questions/9619030/resolving-javax-net-ssl-sslhandshakeexception-sun-security-validator-validatore) – Fady Saad May 23 '17 at 03:57

1 Answers1

0

your client doesn't have the certification, you should see this : https://confluence.atlassian.com/kb/unable-to-connect-to-ssl-services-due-to-pkix-path-building-failed-779355358.html

Tang Jia
  • 11
  • 1