我有一个包含以下组件的 Karaf 程序:
- Karaf 4.0.7;
- hibernate 4.3.7;
- Mysql JDBC 连接器 5.1.27;
- C3P0 0.9.5。
我刚刚设置了一个新的开发环境,我正在使用 Mysql 8.0.11(最近才发布)。我已经在本地将我的 Mysql Connector 升级到 5.1.46,因此它与 Mysql 8 兼容,并且大部分情况下都能正常工作。但是,我在 Karaf 控制台中收到一些关于 SSL 的警告:
Wed Apr 25 09:28:29 CEST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
我想在本地禁用 SSL,但将 &useSSL=false
添加到连接字符串末尾的建议不起作用。这是我的连接字符串:
hibernate.connection.url=jdbc:mysql://localhost:3306/dbname?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&requireSSL=false
我做错了什么?
最佳答案
遇到MySql & Hibernate SSL Connection之后,我发现在这种情况下,useSSL 和 requireSSL 属性不应该像使用 Tomcat webapp.xml 文件那样添加到 jdbc url(我最初认为它会起作用),而是作为单独的 hibernate.connection.useSSL
和 hibernate.connection.requireSSL
属性。
用法:
hibernate.connection.useSSL=false
hibernate.connection.requireSSL=false
将这两行添加到我在 karaf 中的 hibernate.properties 文件中删除了警告。
关于带有 Hibernate 和 C3P0 : How do I disable connecting through SSL? 的 Mysql 8.0.11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50022690/