Skip to content
Advertisement

How do I get OpenJDK 16 to talk with an SSL enabled nginx server?

I’m running a spring boot application that needs to make an https call to an nginx server. The application is running on CentOS 7 with OpenJDK 16.

Following this more or less, I gathered a list of all the ciphers available to the JVM:

JavaScript

In nginx, I have the following:

JavaScript

I’ve tried every one of the ciphers available to my JVM in place of ...keys here... and they all result in nginx failing to start with:

JavaScript

I can add a list more like I would expect, such as:

JavaScript

nginx starts at this point – and most applications like Chrome, wget, etc are fine with it. Oracle’s JDK 11 on my laptop also connects to it without issue. However the OpenJDK based application refuses to connect:

JavaScript

I also ran across this – I’m assuming this means that the JDK cipher named TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 for instance should be DHE-RSA-AES256-GCM-SHA384 in nginx/OpenSSL. So I tried a modified cipher list in nginx of:

JavaScript

but still the same result. In the nginx logs:

JavaScript

and in the Java service logs:

JavaScript

I can’t seem to find any good documentation on adding additional ciphers to the JVM, only enabling ones that are present but not enabled for some reason. I’ve seen some vague references to BouncyCastle, but unclear how to properly use that for this purpose, especially since I won’t be creating the sockets myself (using a library that needs to make the call).

I also can’t seem to figure out how to configure nginx/OpenSSL to enable additional ciphers to support what the Java application is expecting. I’m using nginx 1.21.6 and OpenSSL 1.1.1k.

So… How do I add/configure ciphers to make the two play well together?

Advertisement

Answer

For me, the issue came down to an outdated installation of OpenSSL.

I mistakenly read the OpenSSL version from the docker host (1.1.1x) instead of from the container (don’t remember the version, but was from 2017). Unfortunately, this can’t easily be updated in CentOS 7 – nothing from the package manager, and compiling from source runs into all sorts of issues. But once past those issues, the list of ciphers was about 5x as long and the connection worked fine.

I then switched to Ubuntu 20.04, which made the installation of OpenSSL much easier (1.1.1f comes standard from the package manager). SSL handshake went through as expected.

On to the next problem – even with a successful SSL negotiation, for some reason all SSL connections are timing out after 25ms… but that’ll be another topic (here for anyone going down the same rathole as I am).

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement