Created
May 31, 2017 15:01
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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