-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error tls: handshake failure
on try to connect to mysql 5.7 with SSL client certs
#1635
Comments
https://dev.mysql.com/blog-archive/ssltls-improvements-in-mysql-5-7-10/ MySQL 5.7 may not support TLS v1.2. You should check your MySQL configuration and tweak MinVersion if TLS v1.2 is not supported. |
Support of TLS v1.2 in mysql 5.7.44 enabled by default. I tried specifying MinVersion TLS v1.2, it didn't do anything. |
How did you confirm it on your MySQL server? |
Here is my connection from console mysql -u root -p -h 192.168.8.53 --ssl-ca=ca.pem --ssl-cert=client-cert.pem --ssl-key=client-key.pem
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.44 MySQL Community Server (GPL) Here is server settings and my connection status: mysql> SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------+
| Variable_name | Value |
+-------------------------+------------------------------+
| innodb_version | 5.7.44 |
| protocol_version | 10 |
| slave_type_conversions | |
| tls_version | TLSv1,TLSv1.1,TLSv1.2 |
| version | 5.7.44 |
| version_comment | MySQL Community Server (GPL) |
| version_compile_machine | x86_64 |
| version_compile_os | Linux |
+-------------------------+------------------------------+
8 rows in set (0.03 sec)
mysql> SELECT
-> variable_value AS tls_version,
-> processlist_user AS user,
-> processlist_host AS host
-> FROM performance_schema.status_by_thread sbt
-> JOIN performance_schema.threads t
-> ON (t.thread_id = sbt.thread_id)
-> WHERE variable_name = 'Ssl_version'
-> ORDER BY tls_version;
+-------------+------+------------+
| tls_version | user | host |
+-------------+------+------------+
| TLSv1.2 | root | 172.18.0.1 |
+-------------+------+------------+
1 row in set (0.02 sec) |
The next suspect is the cipher suite. |
No information about cipher suites? |
I'm experiencing the same problem. Still investigating, but so far it appears to be caused by Go 1.22+ default removing the cipher suites which used RSA based key exchange. (See https://go.dev/doc/go1.22#library and scroll to crypto/tls: "By default, cipher suites without ECDHE support are no longer offered by either clients or servers during pre-TLS 1.3 handshakes") Here's what I've found so far when testing against a stock "mysql:5.7" Docker image: With a Go 1.22+ client program and a MySQL 5.7 server, the "tls: handshake failure" seems to happen when simply using Using Setting env var Alternatively, using "go 1.21" in go.mod and recompiling also fixes it, since this reverts the standard library. Percona Server for MySQL 5.7 does not exhibit this error at all, presumably because they use a better cipher suite list. Given all the above findings, I expect this is also fixable by setting tls.Config.CipherSuites to include the IDs from That all said, it would be good if there was a clean way for |
I did more research and testing across different MySQL and MariaDB versions.
Summary: In a sense, there's no "bug" here. It is arguably the calling code's responsibility to set cipher suites and minimum TLS version. Instead just some potential feature requests:
One easy win could be some minor documentation improvements, describing how it's up to the caller to configure cipher suites and min TLS version if connecting to older servers. I'm happy to submit a PR next week, which adds a couple sentences to the README, if this would be helpful. |
Issue description
Failed to connect to mysql server version 5.7.44 using SSL client certificates. An error is returned. Everything works correctly with mysql server version 8.4.2.
Example code
Error log
Configuration
v1.8.1
Go version: go version go1.22.6 darwin/arm64
Server version: MySQL 5.7.44
Server OS: oraclelinux7
The text was updated successfully, but these errors were encountered: