Skip to content

Instantly share code, notes, and snippets.

@Firefishy
Created October 20, 2015 12:42
Show Gist options
  • Save Firefishy/b2e606c42edcc4f513ba to your computer and use it in GitHub Desktop.
Save Firefishy/b2e606c42edcc4f513ba to your computer and use it in GitHub Desktop.
Java test HTTPS request to https://helloworld.letsencrypt.org/
// Based on java example: http://docs.oracle.com/javase/tutorial/networking/urls/readingWriting.html
// save as: URLConnectionReader.java
// compile using JDK: javac URLConnectionReader.java
// run: java URLConnectionReader
// good path: returns HTML
// bad path: throws an exception
import java.net.*;
import java.io.*;
public class URLConnectionReader {
public static void main(String[] args) throws Exception {
URL oracle = new URL("https://helloworld.letsencrypt.org/");
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
@g0ddest
Copy link

g0ddest commented Oct 25, 2016

java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

Error still there.

@yglodt
Copy link

yglodt commented Oct 31, 2016

This SO-answer shows how to import the letsencrypt security chain, which "solves" the issue, even on a Raspberry Pi with jre 1.8.0_65:

http://stackoverflow.com/a/35454903/272180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment