SQL Ant 任务:警告:不建议在没有服务器身份验证的情况下建立 SSL 连接

SQL Ant Task: WARN: Establishing SSL connection without server's identity verification is not recommended

我是 运行 一个 ant task 在 MySQL-5.7 服务器上做一些 SQL,我不想使用 SSL。我目前正在使用 mysql-connector-java-5.1.42.jar 连接到 MySQL-5.7 (v5.7.18-0ubuntu0.16.04.1)

我的 SQL 属性如下所示

<sql
    url="jdbc:mysql://mysql.box.lan:3306/mydb?autoReconnect=true&amp;useSSL=false&amp;verifyServerCertificate=false"
    userid="my-user"
    password="xxx"
    driver="com.mysql.jdbc.Driver"
    onerror="continue"
    showWarnings="false"
    delimiter=";"
    encoding="UTF-8">

不幸的是,驱动程序似乎并不关心 autoReconnectuseSSL and/or verifyServerCertificate 的任何组合,如前所述 , here and here.

准确的错误是

Thu Jun 22 12:20:32 GMT 2017 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.

这个怎么样:

<sql
    url="jdbc:mysql://mysql.box.lan:3306/mydb"
    userid="my-user"
    password="xxx"
    driver="com.mysql.jdbc.Driver"
    onerror="continue"
    showWarnings="false"
    delimiter=";"    
    encoding="UTF-8">
    <connectionProperty name="useSSL" value="false" />
    <connectionProperty name="verifyServerCertificate" value="false" />
    <connectionProperty name="autoReconnect" value="true" />
</sql>

我猜 ant 不会解析连接 url properties/doesn不会使用它们进行连接。这似乎是 "logical" 尝试使用 connectionProperty 设置单个值

的事情

https://ant.apache.org/manual/Tasks/sql.html