Skip to content

Instantly share code, notes, and snippets.

@cdman
Created May 10, 2018 16:00
Show Gist options
  • Save cdman/5a7788af5157859e6888ea4c516f7614 to your computer and use it in GitHub Desktop.
Save cdman/5a7788af5157859e6888ea4c516f7614 to your computer and use it in GitHub Desktop.
Java SSL test
import java.io.InputStream;
import java.net.URL;
import java.util.Map.Entry;
public final class Main {
public static void main(String... args) throws Exception {
printSSLProperties();
URL url = new URL("https://dv3.datavalidation.com/");
System.out.println("Downloaded " + readAll(url.openStream()) + " bytes");
}
private static final long readAll(InputStream ins) throws Exception {
long result = 0;
byte[] buf = new byte[1024];
while (true) {
int r = ins.read(buf);
if (r == -1) {
break;
}
result += r;
}
return result;
}
private static void printSSLProperties() {
for (Entry<Object, Object> entry : System.getProperties().entrySet()) {
String key = entry.getKey().toString();
if (!key.contains("ssl")) {
continue;
}
System.out.println(key + "=" + entry.getValue());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment