Yrlec
Yrlec

Reputation: 3458

Java + SSL using custom Socket

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?

Upvotes: 0

Views: 609

Answers (1)

Bruno
Bruno

Reputation: 122599

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).

Upvotes: 1

Related Questions