Mysql 带有 Hibernate 和 C3P0 的 8.0.11:如何禁用通过 SSL 的连接?

Mysql 8.0.11 with Hibernate and C3P0: How do I disable connecting through SSL?

我有一个包含以下组件的 Karaf 程序:

  1. 卡拉夫 4.0.7;
  2. 休眠 4.3.7;
  3. Mysql JDBC 连接器 5.1.27;
  4. C3P0 0.9.5.

我刚刚设置了一个新的开发环境,我正在使用 Mysql 8.0.11(最近才发布)。我已经在本地将我的 Mysql 连接器升级到 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 属性不应添加到 jdbc url 中,就像使用Tomcat webapp.xml 文件(因为我最初认为它会起作用),而是作为单独的 hibernate.connection.useSSLhibernate.connection.requireSSL 属性添加。

用法:

hibernate.connection.useSSL=false
hibernate.connection.requireSSL=false

将这两行添加到我在 karaf 中的 hibernate.properties 文件中删除了警告。