Created
November 14, 2018 12:15
-
-
Save tekbird/65caffe57f79a9e716fa9db799511b23 to your computer and use it in GitHub Desktop.
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
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