I have received this request a couple of time and thus I have decided to post a blog in order to explain how to do it.
Hapi provides a test panel app that allows a user to easily use the library in order to send or receive HL7 messages. That GUI provides a check box for using TLS.
The IHE ATNA profile requires mutual authentication, this means that the client AND the server need to provide a certificate in order to reach successful TLS negociation. Checking the TLS box does not tell hapi which certificate to use.
What most people are forgetting is that they need to configure Java to tell what certificate to use when initiating the TLS communication and what certificate to trust. In order words, the user who would like to use TLS, needs to provide java with the pointer to the truststore (list of certificate to trust) and the pointer to the keystore (certificate to use to initiate TLS).
The easiest way to do it without breaking the entire java installation is to provide some arguments to the call to java.