Skip to content

fix: allow public key retrieval for MySQL family datasources - #48

Open
LordofAvernus wants to merge 1 commit into
dev/4.3.4from
fix/mysql-allow-public-key-retrieval-434
Open

LordofAvernus wants to merge 1 commit into
dev/4.3.4from
fix/mysql-allow-public-key-retrieval-434

Conversation

@LordofAvernus

Copy link
Copy Markdown
Collaborator

关联的 issue

https://github.com/actiontech/dms-ee/issues/989

描述你的变更

  • MySQLConnectionExtension.appendDefaultJdbcUrlParameters 默认补 allowPublicKeyRetrieval=true,修掉 MySQL 8 caching_sha2_password 账号在认证缓存未命中时报 Public Key Retrieval is not allowed 的问题(ODC 拼串固定 useSSL=false,驱动在非 SSL 下默认禁止取服务端公钥)
  • putIfAbsent 保证数据源自带的 jdbcUrlParameters 优先,需要走 SSL 的场景可显式配 false 覆盖
  • 参数 map 改为拷贝后再写,不再就地修改调用方传入的 map:DataSourceInfoMapperCollections.emptyMap(),原实现在 DLM 路径会抛 UnsupportedOperationException;入参为 null 时原实现还会静默丢掉默认参数
  • 改动只落在 MySQL 连接插件,未动 OBMySQLConnectionExtensionOBConsoleDataSourceFactory;生效类型为 MYSQLDORISTIDB(后两者继承且未覆写该方法),不影响 OceanBase / Oracle / PostgreSQL 等
  • 新增 MySQLConnectionExtensionTest(纯单测,不依赖真库)6 个用例:默认值生效、用户显式 false 不被覆盖、null 入参、不可变 map 不抛异常、调用方 map 不被污染、不串入 OceanBase 专有的 enableFullLinkTrace

自测记录:./mvnw -Dci -pl server/plugins/connect-plugin-mysql -am -Dmaven.test.skip=false -Dtest=MySQLConnectionExtensionTest test(JDK 8)6 项全绿,formatter / license / impsort 校验通过。回滚实现后同组用例 4 项失败,其中不可变 map 用例确实抛出 UnsupportedOperationException

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc

MySQL 8 defaults to caching_sha2_password. When the server side
authentication cache misses, the driver has to fetch the server RSA
public key to encrypt the password, but ODC builds the JDBC url with
useSSL=false and without allowPublicKeyRetrieval, so Connector/J
refuses the retrieval and the connection fails with "Public Key
Retrieval is not allowed".

Default allowPublicKeyRetrieval to true in the MySQL connect plugin so
test connection, SQL console, data transfer and DLM all get it. Values
supplied by the datasource still win, and TiDB / Doris inherit it.

Also build the parameter map from a copy instead of mutating the
caller's map: DataSourceInfoMapper passes Collections.emptyMap(), which
made the previous in-place put throw UnsupportedOperationException, and
a null map silently dropped the defaults.
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

Successfully merging this pull request may close these issues.

1 participant