question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TLS version incompatibility when using latest JDKs with MySQL <8

See original GitHub issue

Hi! I’ve been working on fixing an issue in Testcontainers’ test suite, and found a related issue here as well.

https://bugs.openjdk.java.net/browse/JDK-8202343 has disabled TLS1 and TLS1.1 in the latest versions of JDKs, and this seems to be particularly troublesome for connections to legacy versions of MySQL (e.g. 5.6, 5.7).

Following this (quite surprising) change to the JDK, the SslBridgeHandler code here is now capable of producing an invalid set of TLS protocols when using:

  • An up to date OpenJDK, e.g. 1.11.0-11
  • A MySQL server version <=8.0.4 (even though, per docs and my own testing, >=5.7.28 and >=5.6.46 are capable of using TLS1.2)

With this combination of new and old, r2dbc-mysql is choosing to use TLS1.1/TLS1, which quickly fails with:

Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

I’d imagine that a small tweak to the isEnabledTls1_2 function would allow TLS1.2 to be used with older MySQL versions that can use it, so that the library is less inclined to try to use one of the disabled protocols. It might be good to fail-fast as well, with an informative exception when this incompatibility arises.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mirromutthcommented, Oct 2, 2021

Hi there,

Great thanks for your report. Apologies for the late reply.

I think isEnabledTls1_2 should be changed and SslBridgeHandler need print a warn log if it matches TLS1.1 or earlier.

I’m following up on this ticket, it should be resolved soon.

1reaction
hongjunancommented, Jun 7, 2021

i have had same issue. latest jdk(11.0.11+9) doesn’t support TLSv 1.0, 1.1. so you have to specify tls version exaclty. like below

r2dbc:mysql://testdb-mysql:3306/testdb?tlsVersion=TLSv1.2
Read more comments on GitHub >

github_iconTop Results From Across the Web

Connection to MySQL and TLS version with OpenJdk 1.8.0_292
Description: When trying to connect to a MySQL Server using OpenJDK 1.8.0_292, we get this exception: com.mysql.cj.exceptions.
Read more >
Why can Java not connect to MySQL 5.7 after the latest JDK ...
Try adding 'enabledTLSProtocols=TLSv1.2' to MySQL connection string. This will enforce TLSV1.2 protocol for java's mysql connection and you ...
Read more >
JDK 8 will use TLS 1.2 as default - Oracle Blogs
JDK 8 will use TLS 1.2 as default · TLS is backwards-compatible. After upgrading the default to 1.2, systems using 1.1 and 1.0...
Read more >
MySQL JDBC Error: javax.net.ssl.SSLHandshakeException
A recent Java update, specifically Red Hat/CentOS, disables TLSv1 and TLSv1.1 by default for Java 8 · The MySQL JDBC driver will attempt...
Read more >
Cannot connect to a database because of ... - JetBrains
Note that it might result in vulnerability issues. Consider using newer versions of TLS. MySQL. Open ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found