MySQL: with use_tls=False, 2.3.6 needs the cryptography package to log in to MySQL 8
维护者通常 5 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- mysql, python
调研方向
从 pyproject.toml 开始,其中声明了 pymysql>=1.1.1,将其替换为 pymysql[rsa]>=1.2.4;如果元数据在 setup.py/setup.cfg 中,也一并检查。然后添加 2.3.7 发布说明条目,说明 use_tls=False 表示自 2.3.6 起不使用 TLS,并且 MySQL 8 登录现在需要 cryptography 加上 PyMySQL 1.2.4+。在 conda-forge recipe 中同步该 pin。当没有 cryptography 的全新安装能够以 use_tls=False 连接到 mysql:8.0 容器,并且该说明已发布时,即完成。
由索引模型根据 Issue 内容生成。
描述
Summary
Since 2.3.6, use_tls=False turns TLS off on MySQL; in 2.3.5 the connection still used TLS. Without TLS, PyMySQL needs the cryptography package to log in with MySQL 8's default authentication (caching_sha2_password) whenever the server has no cached login for the account. datajoint does not depend on cryptography, so after upgrading to 2.3.6 such a connection fails:
RuntimeError: 'cryptography' package is required for sha256_password or caching_sha2_password auth methods
The server caches a login after the account's first login over TLS or a local socket, so the error is intermittent in practice: it appears after a server restart, FLUSH PRIVILEGES, a password change, or for a new account.
Reproduction
A fresh mysql:8.0 container, use_tls = False, and a check of the session's cipher:
import datajoint as dj
dj.config["database.use_tls"] = False
conn = dj.conn(reset=True)
conn.query("SHOW SESSION STATUS LIKE 'Ssl_cipher'").fetchall()
| DataJoint | Ssl_cipher |
|---|---|
| 2.3.5 | TLS_AES_256_GCM_SHA384: TLS was used although use_tls=False |
| 2.3.6 | empty: no TLS, as configured |
The test suite of https://github.com/datajoint/dj-png-codecs shows the effect. It sets use_tls = False against a fresh MySQL 8.0 container. With datajoint 2.3.5, all tests pass. With 2.3.6, the first connection raises the RuntimeError above (https://github.com/datajoint/dj-png-codecs/pull/9).
PostgreSQL connections are not affected.
Expected
use_tls=False keeps working after an upgrade, without a dependency the user has to discover from a PyMySQL error.
PyMySQL 1.2.1 to 1.2.3
With cryptography installed, the same login still fails on PyMySQL 1.2.1, 1.2.2 and 1.2.3:
AttributeError: 'NoneType' object has no attribute 'is_auth_switch_request'
In those releases, caching_sha2_password_auth (pymysql/_auth.py) sends the RSA-encrypted password but does not return the server's reply. PyMySQL 1.2.0 and 1.2.4 return it, and the login succeeds. The dj-png-codecs suite with datajoint 2.3.6 and cryptography passes on PyMySQL 1.1.2, 1.2.0 and 1.2.4, and fails on 1.2.1 to 1.2.3.
Proposed fix
- Depend on
pymysql[rsa]>=1.2.4instead ofpymysql>=1.1.1. Thersaextra installscryptography, which PyMySQL documents as required forcaching_sha2_passwordandsha256_passwordwithout TLS. The floor leaves out 1.2.1 to 1.2.3, and keeps the fix for CVE-2024-36039 that the current floor is for. - Say in the 2.3.7 release notes that
use_tls=Falsedisables TLS since 2.3.6, and that such connections to MySQL 8 needcryptographyand PyMySQL 1.2.4 or later, which 2.3.7 installs. - Apply the same requirements in the conda-forge recipe.
- 主要语言
- Python
- 星标
- 198
- 派生
- 103
- 平均合并
- 5 天 1 小时
- 30 天内合并 PR
- 12
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
datajoint/datajoint-python 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
datajoint/datajoint-python#1747 ·
维护者通常 5 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
datajoint/datajoint-python#1712 ·
维护者通常 5 天内回复
-
Decoding a <blob> value in an unknown format returns None instead of raising an error可能已有人在做 @godara-alt 于 3 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
datajoint/datajoint-python#1703 ·
维护者通常 5 天内回复
-
Character matrices with more than one row come back transposed from <blob>可能已有人在做 @godara-alt 于 2 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
datajoint/datajoint-python#1702 ·
维护者通常 5 天内回复
-
staged_insert1 stores object paths with the class name and an empty store name, so garbage collection can delete its objects可能已有人在做 @godara-alt 于 3 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
datajoint/datajoint-python#1701 ·
维护者通常 5 天内回复
查看 datajoint/datajoint-python 的全部 Issue
相似的 Issue
-
bug game: 0100FF500E34A000 game: 0400FF500E34A001 mac packing
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
jxxghp/MoviePilot#7576 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 64/100
jbaruch/software-factory#266 ·
维护者通常 1 天内回复
-
cron: raise a distinct error when next_fire finds no match in its search bound (from #813 item 5)未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复