0

I'm developing a Java based P2P application where the peers are communicating with each using a library called ice4j and it's custom socket called PsuedoTCPSocket.

I now want to add SSL support to the application. PsuedoTCPSocket extends java.net.Socket so think it should possible to just use a SSLSocket on top of that socket. However I'm not able to find any way to create SSLSocket-instances using a custom underlying Socket. Is this possible and if so how do I achieve it?

1 Answer 1

1

If your PseudoTCPSocket extends java.net.Socket (and doesn't break its API), you should be able to upgrade it to an SSLSocket using SSLSocketFactory.createSocket(Socket s, String host, int port, boolean autoClose).

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks that looks like a great option! However, I can't find the corresponding function for SSLServerSockets. SSLServerSocketFactory doesn't seem to have any createServerSocket function that enables you to give it a custom Socket. Am I supposed to use SSLSocket at both peers or am I missing something?
SSLSocket are not in server or client mode until the handshake. Use SSLSocket.setUseClientMode(false) on the server before the handshake if you want a server socket.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.