Socket fromServer = new Socket("host", 443);
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) factory.createSocket(fromServer, null, true);
sslsocket.setUseClientMode(true);
i try it, but get "javax.net.ssl.SSLException: Received fatal alert: internal_error"
If i use SSLSocket directly it work (factory.createSocket("host", 443);)
add: i need add custom header BEFORE handshake, for implement custom protocol
add2: Code works! it my fail, i test on server with SNI