Skip to content

Instantly share code, notes, and snippets.

@tekbird tekbird/client.java
Created Nov 14, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.