Home

Awesome

Server and Client implementation with SSLEngine

Implementation of a Java SSL/TLS server and client, making use of JSSE framework and specifically the SSLEngine class.

An introduction to JSSE

JSSE is the standard way Java provides to implement SSL/TLS communication. One of its core classes is SSLContext, which you can easily configure and equally easily get an input and output stream from. These streams though will be blocking, since available() will always return false for SSL/TLS connections. In order to achieve a non-blocking SSL/TLS solution, JSSE provides the SSLEngine, which leads to a more complicated solution, since the developer has to implement parts of the protocol himself and also decide the way the transport link will be implemented. Due to the lack of examples I was able to find in the Internet, I decided to start a project, in order to explore JSSE, and share it here. More information about JSSE can be found in this link: https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/JSSERefGuide.html

The implementation

There are 3 Java classes in the project:

Example

In project's test directory there is a Demo class that contains an example of NioSslClient's and NioSslServer's usage. It creates and starts a thread running a server and then creates 4 clients, connect them to the server, send messages to it and read the responses.

Get the project

You can clone the project and build it with maven to run the example and check the code. I used Maven 3.3, Java 1.8 and log4j 1.2 for the logging. The project is under MIT license, so I would be glad if you would like to contribute!