How can I create a PSK connection between the Eclipse PAHO Java MQTT client and the Mosquitto broker?-Collection of common programming errors

I am trying to configure a Pre Shared Key encrypted connection between a mosquitto mqtt broker and an application written in Java which uses the Eclipse Paho client library.

I have successfully made connections between the two using no encryption and using SSL where the Server certificate is authenticated but with no client certificate.

I would like to get the connection encrypted (authentication not important) by using a Pre Shared Key, which is definitely supported by the mosquitto broker, but I am uncertain whether the Eclipse Paho library supports it or not.

The library offers you two different ways of configuring a secure connection. Either through the

setSSLProperties(java.util.Properties props)

method – making use of the following properties:

com.ibm.ssl.protocol
com.ibm.ssl.contextProvider
com.ibm.ssl.keyStore
com.ibm.ssl.keyStorePassword
com.ibm.micro.security.Password.obfuscate(char[] password). 
com.ibm.ssl.keyStoreType
com.ibm.ssl.keyStoreProvider
com.ibm.ssl.trustStore
com.ibm.ssl.trustStorePassword
com.ibm.micro.security.Password.obfuscate(char[] password).
com.ibm.ssl.trustStoreType
com.ibm.ssl.trustStoreProvider
com.ibm.ssl.enabledCipherSuites
com.ibm.ssl.keyManager
com.ibm.ssl.trustManager

or through the

setSocketFactory(javax.net.SocketFactory socketFactory)

method.

Does anyone have any experience with the tools and libraries that I am using and could anyone offer any suggestions as to how I might be able to get something working?

Is it possible to create an ssl socket factory which is capable of returning a socket that can cope with the PSK implementation I will need?

Thanks for your help 🙂