5

My remote MySQL server only accepts connections over TLS 1.2. How do i select protocol version in JDBC (OpenJDK 11)?

SQL State: 28000
java.sql.SQLException: TLS version used does not meet minimal requirements
for this server. Please use a higher TLS version and retry.
<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>8.0.21</version>
</dependency>

I've tried adding enabledSslProtocolSuites to my connection string but to no avail.

jdbc:mysql://{server}.mysql.database.azure.com:3306/{database_name}?
  serverTimezone=Australia/Melbourne&useSSL=true&requireSSL=true&enabledSslProtocolSuites=TLSv1.2

Adding -Djdk.tls.client.protocols="TLSv1.2" -Djavax.net.debug=all when launching mvn exec:java reveals attempts to Client Hello with TLS 1.1.

javax.net.ssl|DEBUG|0C|azuremysqltest.App.main()|
2020-08-31 09:16:34.400 UTC|ClientHello.java:653|
Produced ClientHello handshake message (
"ClientHello": {
  "client version"      : "TLSv1.1",
  "random"              : "0D 94 D2 90 A7 C0 ...",
  "session id"          : "",
  "cipher suites"       : ...
evilSnobu
  • 24,582
  • 8
  • 41
  • 71
  • 1
    Please try `enabledTLSProtocols=TLSv1.2` instead of `enabledSslProtocolSuites...` (https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html, https://stackoverflow.com/q/55129768/592355 ...) – xerx593 Aug 31 '20 at 09:25
  • 1
    Excellent, that works, thanks! Please add that as an answer. – evilSnobu Aug 31 '20 at 09:41

1 Answers1

8

You can (obviously) select the TLS version for the mysql driver (java vendor independently) via the enabledTLSProtocols property (8.0 reference):

  • enabledTLSProtocols

If "useSSL" is set to "true", overrides the TLS protocols enabled for use on the underlying SSL sockets. This may be used to restrict connections to specific TLS versions. |Since|Version 8.0.8|

In your case the value =TLSv1.2 approved working. Sorry I can't find the reference on the (exact) value(s) of this property, but we can further investigate/get supported ssl protocol versions like here.

xerx593
  • 12,237
  • 5
  • 33
  • 64