Skip to content

Instantly share code, notes, and snippets.

@jalogisch
Last active August 17, 2018 13:28
Show Gist options
  • Save jalogisch/554a43dfe31ef31608578cfc8f956c48 to your computer and use it in GitHub Desktop.
Save jalogisch/554a43dfe31ef31608578cfc8f956c48 to your computer and use it in GitHub Desktop.
This little tool will help you to test if your Graylog server is able to reach the Graylog License API - the parameters of the trustStore and the proxy might be added and modified to fit your local needs.
// 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 -Djavax.net.ssl.trustStore=/path/to/cacerts.jks -Dhttp.proxyHost=10.0.0.100 -Dhttp.proxyPort=8800 URLConnectionReader
// if additional debugging is needed add -Djavax.net.debug=all to the above
// 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://api.graylog.com/");
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