centos 错误2026 - SSL连接错误- Ubuntu 20.04

lpwwtiir  于 2022-11-07  发布在  其他
关注(0)|答案(7)|浏览(349)

我最近升级了我的本地机器操作系统从Ubuntu 18.04到20.04,我正在CentOS(AWS)上运行我的MySQL服务器。升级后每当我试图连接到MySQL服务器时,它都会抛出SSL连接错误。

$ mysql -u yamcha -h database.yourproject.com -p --port 3309

ERROR 2026 (HY000): SSL connection error: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol

但是如果我传递--ssl-mode=disabled选项,我就可以远程连接。

$ mysql -u yamcha -h database.yourproject.com -p --port 3309 --ssl-mode=disabled

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 22158946
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

查询:

1.如何在不传递--ssl-mode=disabled的情况下连接
1.如何在我的Django应用程序中传递--ssl-mode=disabled选项,目前我已经定义了它,如下所示,但我仍然得到相同的错误。

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'yamcha',
        'USER': 'yamcha',
        'PASSWORD': 'xxxxxxxxxxxxxxx',
        'HOST': 'database.yourproject.com',
        'PORT': '3309',
        'OPTIONS': {'ssl': False},
    }
o75abkj4

o75abkj41#

Ubuntu 20提高了安全级别。我唯一能连接的方法是允许TLS 1。
编辑此文件:

/usr/lib/ssl/openssl.cnf

又放了开头的文件:

openssl_conf = default_conf

在文件的最后:

[ default_conf ]

ssl_conf = ssl_sect

[ssl_sect]

system_default = ssl_default_sect

[ssl_default_sect]
MinProtocol = TLSv1
CipherString = DEFAULT:@SECLEVEL=1

它帮了我大忙:https://askubuntu.com/questions/1233186/ubuntu-20-04-how-to-set-lower-ssl-security-level

thigvfpy

thigvfpy2#

对于任何在Google上搜索的人,您可以在mysql cmd中使用此标志:--ssl-mode=DISABLED。即:

mysql -uuser -p'myPassw0rd!' -hmysql.company.com --ssl-mode=DISABLED
pvcm50d1

pvcm50d13#

将此文件添加到mysql5.7服务器配置文件中,然后重新启动mysql服务

[mysqld]
tls_version=TLSv1.2

现在,您应该能够使用tls1.2连接到它,这是Ubuntu 20.04中的默认设置
为了完整起见,在Ubuntu 20.04中,my.cnfmysql.cnf实际上是同一个文件,所以编辑其中任何一个都可以。

$ readlink -f /etc/mysql/my.cnf
/etc/mysql/mysql.cnf
aij0ehis

aij0ehis4#

mysqlclient迁移到v2.X,其中添加了ssl_mode选项https://github.com/PyMySQL/mysqlclient-python/blob/main/HISTORY.rst

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'yamcha',
        'USER': 'yamcha',
        'PASSWORD': 'xxxxxxxxxxxxxxx',
        'HOST': 'database.yourproject.com',
        'PORT': '3309',
        'OPTIONS': {'ssl_mode': 'DISABLED'},
    }
}
ltqd579y

ltqd579y5#

如果您使用的是MYSQL Workbench:
只需通过编辑连接禁用SSL即可。
1.转到连接面板中的编辑连接
1.在参数后的选项中选择SSL,如屏幕截图中所示。

1.选择使用SSL:否

1.最后它会看起来像这样。

在Mysql Workbench以外的客户端上,您也可以尝试停用SSL

qcuzuvrc

qcuzuvrc6#

如果你仍然想要升级的安全特性,那么你可以考虑将你的mysql服务器升级到5.7。

hvvq6cgz

hvvq6cgz7#

我也遇到了同样的问题。把上面的想法和文档结合起来。https://dev.mysql.com/doc/refman/5.7/en/encrypted-connection-protocols-ciphers.html#encrypted-connection-supported-protocols
这是我的想法
1.通过$ openssl version检查操作系统的openssl版本及其支持的ssl/tls版本。检查系统设置/etc/ssl/openssl.cnf以及。
1.通过SHOW GLOBAL VARIABLES LIKE 'tls_version';检查MySQL支持TLS版本
1.检查您的python mysql客户端TLS版本。根据我的经验,我使用的是mysql-connector-python。文档说自8.0.28起将不支持TLS 1.1及以下版本。这就是为什么我无法连接到MySQL。https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html
在MySQL文档中,它提到客户端可以使用的TLS版本应该是主机操作系统TLS版本和MySQL TLS版本的并集。
例如,您的主机仅支持TLS 1.1 / 1.2和MySQL设置si TLS 1.0。客户端没有兼容的TLS版本。
希望这些提示能有所帮助。

相关问题