Skip to content

Instantly share code, notes, and snippets.

Created July 18, 2013 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a2c4a8ac8f9e38e22edf to your computer and use it in GitHub Desktop.
Save anonymous/a2c4a8ac8f9e38e22edf to your computer and use it in GitHub Desktop.
package com.xgen.svc.mms.util;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
public class SSLSocketTest {
private static int count = 0;
public static void main(String[] args) throws Exception {
System.setProperty("javax.net.ssl.trustStore", "/opt/10gen/mms/conf/mms.combined.keystore");
System.setProperty("javax.net.ssl.trustStorePassword", "mongoadmin");
final SocketFactory factory = SSLSocketFactory.getDefault();
final InetAddress localhost = InetAddress.getLocalHost();
while(true) {
System.out.println("Count: " + (++count));
final Socket socket = factory.createSocket(localhost, 27017);
final OutputStream out = socket.getOutputStream();
out.write(createMessage());
out.flush();
out.close();
socket.close();
}
}
private static byte[] createMessage() {
/*return new byte[] {1};*/
return new byte[] {0, 0, 0, 0, 106, 0, 0, 0, 0, 0, 0, 0, -41, 7, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 59, -25, 126, 46, -2, 62, 4, 0};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment