Open LeeMendelowitz opened 9 months ago
If anybody is experimenting this issue, switch to the aiomysql driver, it works with the following code:
import ssl
settings = YOUR_SETTINGS
ssl_context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
ssl_context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
ssl_context.load_verify_locations(settings.SQL_SSL_CA)
ssl_context.load_cert_chain(certfile=settings.SQL_SSL_CERT, keyfile=settings.SQL_SSL_KEY)
ssl_context.check_hostname = False
ssl_args = {
"ssl": ssl_context
}
engine = create_async_engine(
settings.SQLALCHEMY_DATABASE_URI,
connect_args=ssl_args
)
I'm experiencing an issue where
asyncmy
2.8.0 with Python 3.11 is generating an SSL Bad Handshake with MySQL 8.0.34. I'm not experiencing this issue withasyncmy
when connecting to MySQL 8.0.26. I'm also not experiencing this issue if I switch toaiomysql
and connect to MySQL 8.0.34.So it appears that the issue is specific to
asyncmy
2.8.0 and MySQL 8.0.34.Here is some example code I'm using to reproduce the issue:
which generates output when run against a connection to MySQL 8.0.34:
In case it's helpful, here are some outputs showing the differences in TLS versions between the MySQL 8.0.26 and MySQL 8.0.34 instances I'm using:
MySQL 8.0.26
MySQL 8.0.34