Search code examples
mysqlruby-on-railsrubymysql2

How to use Ruby and mysql2 gem to connect mysql database via TLS1.2


I am having issues connecting to a mysql database over TLSV1.2, using Ruby and the mysql2 gem. The ruby script is running on Windows. I get the following error:

TLS version used does not meet minimal requirements for this server. Please use a higher TLS version and retry.

Based on some research I believe that mysql2 uses the Connector/C library (6.1.1), which seems to be built against YASSL, which only supports up to TLSV1.1. I can successfully connect via TLSV1.1, but if I restrict the connection to TLSV1.2 then I get the above error.

It seems possible to get a version built against OpenSSL, which supports high TLS versions, but I have found conflicting information on whether that is only for the commercial version, or if that is also available via the community edition. Does anyone have expertise in this area and can recommend a possible solution? Is it possible to get mysql2 and a compatible connector which works with TLSV1.2?


Solution

  • You are right about mysql2 using connector/c.

    Not sure where the 6.1.1 version comes from. Did you mean MariaDB-connector-c-3.1.11? who's release notes advertised TLS-1.3 in the openssl version of this.

    I checked the centos8 binary download from the above link and its linked against the system openssl (looking at ldd ./lib/mariadb/libmariadb.so).

    As far as I know there's no community vs enterprise differentiation here.