简体   繁体   中英

Converting Java SSLSocket to unencrypted Socket

I want to take an existing SSL connection that has already exchanged sensitive information using encrypted connection, and switch it back to using the socket unencrypted. I am using SSLServerSocketFactory.createServerSocket which actually listens for requests from client. Now after doing ServerSocket.accept , I get SSLSocket which I use to do an initial exchange of some sensitive information. Once I am done with this exchange I want to use the same socket in an unencrypted manner (like a normal Socket). Is it at all possible?

On the net I get responses that I can use SSLSocketFactory.createSocket and set autoClose to false. I am not sure how that can help, given that SSLServerSocketFactory doesn't have this parameter.

Thanks for any inputs.

Don't use SSLServerSocketFactory . Use ordinary ServerSocket to listen and create an ordinary server-side Socket and give that to SSLSocketFactory.createSocket(Socket,InputStream,boolean) with autoClose=false and if applicable consumed=null. Reading the linked javadoc explains how this workds. After ending the SSL part of the connection, continue using the Socket as desired.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM