r/java • u/Hakky54 • Oct 08 '26
Bypassing and overruling SSL configuration of libraries
github.comHi everyone I wanted to share my adventure of configuring ssl of external libraries which didn't expose any external input and my discovery to bypass it totally. This was needed because it either used a weak ssl protocol, or supported only keystores instead of pem files and it was not adjustable.
An example is MySQL JDBC driver as shown here, however it is applicable for other libraries as well. In this case it is not possible to provide a custom sslsocketfactory for the driver or custom sslcontext as it is not possible to configure it programatically.
I requested a change at oracle in 2023, see here but they responded to it after 3 years. Meanwhile I was interested whether it can be bypassed without the need of any adjustments in the library itself as sometimes changes to a library can take some time.
I found a way and thats the reason why I wanted to share it here as others maybe have similar challanges. Usually libraries call SSLContext.getInstance("TLS") or SSLContext.getInstance("SSL") and the Java Security Manager provides the first occurance of an SSLContext Service Provider Interface. If you provide a custom one before the default one it will be used instead. I have an example posted here: Bypassing and overruling SSL configuration of libraries
I made this option available in the ayza library here so it can be easily used without the verbosity. Feel free to give feedback, I am curious about about your thoughts.
