Skip to content

Instantly share code, notes, and snippets.

@tekbird
Created November 14, 2018 12:15
Show Gist options
  • Save tekbird/65caffe57f79a9e716fa9db799511b23 to your computer and use it in GitHub Desktop.
Save tekbird/65caffe57f79a9e716fa9db799511b23 to your computer and use it in GitHub Desktop.
static final String alphabet = "0123456789ABCDE";
public static void main(String[] args) throws UnknownHostException, IOException {
System.setProperty("javax.net.ssl.trustStore", "C:\\path\\to\\java\\truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "Password1");
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) factory.createSocket("127.0.0.1", 7000);
OutputStreamWriter writer = new OutputStreamWriter(sslsocket.getOutputStream(), "UTF-8");
char[] buffer = new char[9];
Random r = new Random();
for (int i = 0; i < 9; i++) {
buffer[i] = alphabet.charAt(r.nextInt(alphabet.length()));
}
writer.write(buffer);
writer.close();
sslsocket.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment