Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Secure TCP Connections in Java

I was wondering what is the best way to secure a TCP connection in Java. I want communications to my server to only come from authenticated clients and where possible, encrypt the transmitted data.

What sort of issues am I going to need to watch out for and cover, what technologies could I use?

Thanks,

Tim.

like image 314
Tim Avatar asked Jul 01 '11 20:07

Tim


People also ask

How do you create a secure client socket connection in java?

Let's provide an example of how we can create a secured connection to a server: String host = getHost(...); Integer port = getPort(...); SSLSocketFactory sslsocketfactory = SSLSocketFactory. getDefault(); SSLSocket sslsocket = (SSLSocket) sslsocketfactory . createSocket(host, port); InputStream in = sslsocket.

What is SSL and TLS in java?

The SSL and TLS Protocols. The Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols are sets of rules governing server authentication, client authentication, and encrypted communication between servers and clients.


1 Answers

Java offers an extension of sockets that is secure i.e. JSSE which supports SSLv3 and TLS.
It is designed so that your code is similar to handling normal sockets.
You just initialize the SSLContext and configure it to use the certificates to use and various parameters, e.g. client authentication, handshake listener etc and the rest is handled transparently.
Read the tutorial to start on it.

like image 56
Cratylus Avatar answered Sep 23 '22 03:09

Cratylus