MySQL 异常:Public Key Retrieval is not allowed

4 篇文章 0 订阅
2 篇文章 0 订阅

情景还原

后端应用部署启动的时候,时不时地出现 MySQL Public Key Retrieval is not allowed 的错误。

问题探究

在网上检索 MySQL 连接相关资料看到了以下说明:

If the user account uses sha256_password authentication, the password must be protected during transmission; TLS is the preferred mechanism for this, but if it is not available then RSA public key encryption will be used. To specify the server’s RSA public key, use the ServerRSAPublicKeyFile connection string setting, or set AllowPublicKeyRetrieval=True to allow the client to automatically request the public key from the server. Note that AllowPublicKeyRetrieval=True could allow a malicious proxy to perform a MITM attack to get the plaintext password, so it is False by default and must be explicitly enabled.

大概是说如果 MySQL 的密码是通过 SHA256 方式加密认证的,就需要在传输过程中保证连接密码是加密过的。通过将 allowPublicKeyRetrieval 参数设为 true 可以让客户端拿到 RSA 公钥,并以此来保证连接密码是加密的。但开启这个参数同时也会带来另一个问题:黑客可以发起中间人攻击( MITM attack )来获取明文密码。

解决方案

可以通过在 MySQL 连接地址上加上参数 allowPublicKeyRetrieval=true 来解决该问题。但必须注意改动这个参数所带来的弊端。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值