Skip to content
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

custom SSL cert Error different aiomysql #83

Open
panla opened this issue Feb 5, 2024 · 0 comments
Open

custom SSL cert Error different aiomysql #83

panla opened this issue Feb 5, 2024 · 0 comments

Comments

@panla
Copy link

panla commented Feb 5, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant