Last active
October 9, 2019 10:13
-
-
Save alces/6f0a3a0a06dbf74186a75fa269ffa059 to your computer and use it in GitHub Desktop.
Java "one-liner" for testing SSL connections (truststores, client auth, etc)
This file contains hidden or 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
import java.io.*; | |
import java.net.*; | |
/** | |
* Open URL passed as the first command-line argument and read the first line from it | |
* | |
* Example usage for testing client auth: | |
* java -Djavax.net.ssl.trustStore=/path/to/truststore.jks \ | |
* -Djavax.net.ssl.trustStorePassword=myword \ | |
* -Djavax.net.ssl.keyStore=/path/to/keystore.jks \ | |
* -Djavax.net.ssl.keyStorePassword=myword \ | |
* UrlConnectTest https://my.url:port | |
*/ | |
public class UrlConnectTest { | |
public static void main (String args[]) throws IOException, MalformedURLException { | |
InputStream s = new URL(args[0]).openStream(); | |
BufferedReader r = new BufferedReader(new InputStreamReader(s)); | |
System.out.println(r.readLine()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment