增加对mysql的caching_sha2_password认证插件fullauth流程支持 #4767
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
环境描述:
MYSQL服务端版本:8.0.30
Canal:1.1.6
关联Issues: #1700
背景:采用caching_sha2_password插件认证,客户端首次连接MySQL服务端/在MYSQL服务端执行flush privileges;,报caching_sha2_password Auth failed。非首次连接则可以正常认证。
复现情况:稳定复现
原因:
从 MySQL 8.0.4 开始,MySQL 默认身份验证插件从 mysql_native_password 改为 caching_sha2_password。
Canal目前支持了caching_sha2_password插件Fast auth功能。
相关commit为:b95c0d03cf42e8637b72b7f2d2dbfab894bef1aa
非首次连接可以正常认证的原因为触发了caching_sha2_password的Fast Auth功能。
本次代码新增了caching_sha2_password的Full Auth功能中从服务端获取public key,然后进行Auth逻辑。实现了在使用caching_sha2_password插件下Canal可以正常连接MYSQL的功能。
相关文档:https://dev.mysql.com/doc/dev/mysql-server/latest/page_caching_sha2_authentication_exchanges.html
单元测试:
执行了com/alibaba/otter/canal/parse/driver/mysql/MysqlConnectorTest.java