System.setProperty("javax.net.ssl.keyStore", path);
System.setProperty("javax.net.ssl.keyStorePassword", password);
System.setProperty("javax.net.ssl.trustStore", path);
System.setProperty("javax.net.ssl.trustStorePassword", password);
ServerSocketFactory server = SSLServerSocketFactory.getDefault();
// Let the operating system just choose an available port:
ServerSocket serverSocket = server.createServerSocket(0);
serverSocket.setSoTimeout(30000);
int port = serverSocket.getLocalPort();
// System.out.println("\nlistening on port: " + port);
SSLSocketFactory ssf = SSLSocketFactory.getSocketFactory();