-
-
Save anonymous/a2c4a8ac8f9e38e22edf to your computer and use it in GitHub Desktop.
This file contains 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
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