Skip to content

Instantly share code, notes, and snippets.

@neilus
Created May 31, 2017 15:01
Show Gist options
  • Save neilus/56cf461487321a2423f4a0b4a21b4e6e to your computer and use it in GitHub Desktop.
Save neilus/56cf461487321a2423f4a0b4a21b4e6e to your computer and use it in GitHub Desktop.
"Ping" an url so one can determine wether ti's CA is in the JRE's truststore
// 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(args[0]);
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();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment