long2ice / asyncmy

A fast asyncio MySQL/MariaDB driver with replication protocol support
https://github.com/long2ice/asyncmy
Apache License 2.0
230 stars 25 forks source link

custom SSL cert Error different aiomysql #83

Open panla opened 5 months ago

panla commented 5 months ago

custom SSL cert Error different aiomysql

env

code

import ssl

context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS)
context.check_hostname = False
context.load_cert_chain(certfile=cert, keyfile=key)
context.load_verify_locations(ca)
context.verify_mode = ssl.CERT_REQUIRED

conn_params

params = {
    'connections': {
        'default': {
            'engine': 'tortoise.backends.mysql',
            'credentials': {
                '...'
                'ssl': context
            }
        }
    },
    'apps': {
        'models': {
            'models': [
                'models'
            ],
            'default_connection': 'default',
        }
    },
    'use_tz': False,
    'timezone': 'Asia/Shanghai'
}

conn

Tortoise.init(config=params)

error

by same config, when use aiomysql, its ok, and uninstall aiomysql, installasyncmy, its error.

self._pool = await mysql.create_pool(password=self.password, **self._template)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "asyncmy/pool.pyx", line 216, in _create_pool
  File "asyncmy/pool.pyx", line 217, in asyncmy.pool._create_pool
  File "asyncmy/pool.pyx", line 145, in fill_free_pool
  File "asyncmy/connection.pyx", line 1343, in _connect
  File "asyncmy/connection.pyx", line 594, in connect
  File "asyncmy/connection.pyx", line 572, in asyncmy.connection.Connection.connect
  File "asyncmy/connection.pyx", line 831, in _request_authentication
  File "asyncmy/connection.pyx", line 644, in read_packet
  File "asyncmy/protocol.pyx", line 190, in asyncmy.protocol.MysqlPacket.raise_for_error
  File "asyncmy/protocol.pyx", line 194, in asyncmy.protocol.MysqlPacket.raise_for_error
  File "asyncmy/errors.pyx", line 128, in asyncmy.errors.raise_mysql_exception
  File "asyncmy/errors.pyx", line 137, in asyncmy.errors.raise_mysql_exception
asyncmy.errors.OperationalError: (1043, 'Bad handshake')

other

diff pymysql/connection.py and asyncmy/connection.pyx, no significant differences were found on create_ssl.