asyncmy icon indicating copy to clipboard operation
asyncmy copied to clipboard

custom SSL cert Error different aiomysql

Open panla opened this issue 2 years ago • 0 comments

custom SSL cert Error different aiomysql

env

  • os: windows WSL
  • version: asyncmy: 0.2.9

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, install asyncmy, 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.

panla avatar Feb 05 '24 08:02 panla