public SSLSocket createSSLSocket(Socket socket) throws IOException {
  SSLSocketFactory sf=((SSLSocketFactory)SSLSocketFactory.getDefault());
  InetSocketAddress remoteAddress=(InetSocketAddress)socket.getRemoteSocketAddress();
  SSLSocket s=(SSLSocket)(sf.createSocket(socket,remoteAddress.getHostName(),socket.getPort(),true));
  s.setUseClientMode(false);
  s.setEnabledCipherSuites(s.getSupportedCipherSuites());
  return s;
}

public SSLSocket createSSLSocket ( Socket socket ) throws IOException { SSLSocketFactory sf = ( ( SSLSocketFactory ) SSLSocketFactory . getDefault ( ) ) ; InetSocketAddress remoteAddress = ( InetSocketAddress ) socket . getRemoteSocketAddress ( ) ; SSLSocket s = ( SSLSocket ) ( sf . createSocket ( socket , remoteAddress . getHostName ( ) , socket . getPort ( ) , true ) ) ; s . setUseClientMode ( false ) ; s . setEnabledCipherSuites ( s . getSupportedCipherSuites ( ) ) ; return s ; }
create a ssl socket that wraps the existing socket . this method is called after the client issued the starttls command . < p > subclasses may override this method to configure the key stores , enabled protocols / cipher suites , enforce client authentication , etc .
