I'm having issues retrieving the content from some HTTPS sites using the Java 11 HTTPClient. Here's the code I'm using:
HttpClient client = HttpClient.newBuilder().build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://en.wikipedia.org/wiki/Main_Page"))
.build();
HttpResponse<byte[]> response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
System.out.println(response.statusCode());
System.out.println(new String(response.body()));
When trying to download the source of Wikipedia, I get the following error:
java.io.IOException: Received fatal alert: handshake_failure
If I use the same code but change the source URL to https://www.google.com
, it works fine. From a bit of Googling, this makes it sound to me like it's probably an issue with differing crypto algorithms (although I don't know that), but it's not clear to me how to fix it. I've tried a few solutions that have been suggested on other StackOverflow questions, but haven't found one that works for me or a reliable guide to debugging the problem.
Can someone please point me in the direction of what I can try to fix the issue?
$ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)