RabbitMQ
SSL Handshake
JDK 11
Client Issues
Java Development

RabbitMQ client SSL handshake issue on JDK 11

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Secure communication between clients and servers is a critical aspect of modern software systems. RabbitMQ, a popular open-source message broker, supports SSL/TLS for encrypting data in transit. When using RabbitMQ with Java clients, especially with JDK 11, users may encounter issues during the SSL handshake process. This article explores common SSL handshake issues with RabbitMQ clients on JDK 11, providing technical explanations and examples to guide users through troubleshooting and resolution.

Understanding SSL/TLS in RabbitMQ with JDK 11

Secure Sockets Layer (SSL) and its successor, Transport Layer Security (TLS), are protocols for encrypting information over the internet. RabbitMQ utilizes these protocols to secure the data being transmitted between the server and clients. JDK 11, which made significant changes to the way SSL/TLS is handled compared to previous versions, often leads to complications, especially regarding protocol versions and cipher suites.

Key Changes in JDK 11:

  • Removal of TLS 1.0 and 1.1 from default-enabled protocols
  • Introduction of more stringent checks and requirements for certificates
  • Enhanced support for TLS 1.3

Common SSL Handshake Issues

SSL handshake issues generally occur when the client and server fail to agree on the protocol version or cipher suites. These issues may manifest as exceptions in the Java client, such as SSLHandshakeException.

Examples of Exceptions:

  • javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
  • javax.net.ssl.SSLProtocolException: Protocol version or cipher suite mismatch

Causes and Troubleshooting

The following table summarizes common causes of SSL handshake issues and troubleshooting tips:

Issue CauseDescriptionTroubleshooting Tips
Unsupported SSL/TLS versionThe server or client is using a protocol version that is not supported by the other.Ensure both server and client support the same versions. Update your client/server configuration if necessary.
Mismatched cipher suitesThe client and server do not have any cipher suites in common.Configure both client and server to use compatible cipher suites.
Invalid or untrusted certificatesThe SSL certificate used is either self-signed, expired, or not trusted by the other party's trust store.Update the certificate, or update the trust store settings appropriately.
Insufficient cryptographic strengthSome JDK versions limit the strength of cryptographic algorithms (e.g., key length restrictions).Install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files if applicable.

Detailed Troubleshooting Steps

  1. Check Protocol Versions: Verify that both the RabbitMQ server and the JDK 11 client are configured to use compatible SSL/TLS protocol versions. You can use the RabbitMQ configuration file to specify the versions:
erlang
   %% In /etc/rabbitmq/rabbitmq.conf
   ssl_options.versions.1 = tlsv1.2
  1. Verify Cipher Suites: Make sure that the cipher suites enabled in your RabbitMQ server configuration are also supported and enabled in JDK 11:
erlang
   %% In /etc/rabbitmq/rabbitmq.conf
   ssl_options.ciphers = [{rsa,aes_256_cbc,sha256}]

On the client-side in Java:

java
1   SSLContext sslContext = SSLContext.getInstance("TLS");
2   SSLParameters sslParameters = sslContext.getSupportedSSLParameters();
3   String[] enabledCiphers = { "TLS_RSA_WITH_AES_256_CBC_SHA256" };
4   sslParameters.setCipherSuites(enabledCiphers);
5   sslContext.init(null, null, null);
  1. Certificate Management: Ensure that all certificates in the chain are trusted by both the client and server. If using a self-signed certificate, import it into Java's trust store:
bash
   keytool -import -trustcacerts -file mycert.crt -alias myrabbitmqserver -keystore $JAVA_HOME/lib/security/cacerts

Conclusion

SSL/TLS issues in RabbitMQ client-server communication can arise due to various configurations and environmental factors. A systematic approach—starting from verifying protocol versions to managing certificates and cipher suites—can help in effectively resolving these issues. Continuous monitoring and updating of both RabbitMQ and JDK settings are key to maintaining secure and effective communication channels.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.