使用 JDBC 连接 MySQL 时出现 SSL 连接错误
我们在从MySQL 5.6.51
到 MySQL 8.0.27
。 建议的修复对我们有效,但我们有一个问题,因为我们不想更新 Java 源文件以进行更改,例如,从
jdbc:mysql://localhost:3306/Peoples
为
jdbc:mysql://localhost:3306/Peoples?autoReconnect=true&useSSL=false
https://stackoverflow.com/a/34449182
问题:我们是否可以对新目标(Ubuntu内核版本5.4.0-91
)这样我们就不需要对现有的Java代码进行更改?
The problem that we are facing is well documented in https://stackoverflow.com/questions/34189756/warning-about-ssl-connection-when-connecting-to-mysql-database.
We started facing this issue upon transitioning from MySQL 5.6.51
to MySQL 8.0.27
.
The fix that is suggested works for us but we have an issue in that we don’t want to update the Java source files to change, for example, from
jdbc:mysql://localhost:3306/Peoples
to
jdbc:mysql://localhost:3306/Peoples?autoReconnect=true&useSSL=false
as suggested in https://stackoverflow.com/a/34449182
Question: Is there some change that we can make to the execution environment of our new target (Ubuntu kernel version 5.4.0-91
) such that we need not make changes to the existing Java code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用错误消息本身推荐的其他方法来解决 SSL 错误:
(强调我的)
也就是说,创建一个信任库文件,并将路径设置为使用 Java 属性的信任库文件和密码。然后您可以在不更改代码的情况下设置这些属性。
请参阅 https://dev .mysql.com/doc/connector-j/8.0/en/connector-j-reference-using-ssl.html 了解有关创建信任库文件并使用属性将其指定给 Java 应用程序的更多详细信息。
You could resolve the SSL errors using the other method recommended in the error message itself:
(emphasis mine)
That is, create a truststore file, and set the path to the truststore file and the password using Java properties. Then you can set those properties without changing code.
See https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-using-ssl.html for more details on creating the truststore file and use properties to specify it to your Java app.