【问题标题】:Warning: Establishing SSL connection without server's identity verification is not recommended [duplicate]警告:不建议在没有服务器身份验证的情况下建立 SSL 连接 [重复]
【发布时间】:2016-03-17 10:49:15
【问题描述】:

连接 MySQL 数据库时,我收到以下警告:

不建议在没有服务器身份验证的情况下建立 SSL 连接。根据 MySQL 5.5.45+、5.6.26+ 和 5.7.6+ 的要求,如果未设置显式选项,则默认情况下必须建立 SSL 连接。为了符合不使用 SSL 的现有应用程序,verifyServerCertificate 属性设置为“false”。您需要通过设置 useSSL=false 来显式禁用 SSL,或者设置 useSSL=true 并为服务器证书验证提供信任库。

请帮我解决这个问题

import java.sql.*;
public class JdbcCreateTable {
public static void main(String args[])
{
    try
    {
        Class.forName("com.mysql.jdbc.Driver");
    }
    catch(ClassNotFoundException e)
    {
        e.printStackTrace();
    }
    try{
        Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/INTtech","root","root");
        Statement st=con.createStatement();
        int i=st.executeUpdate("create table Author(AID int primary key,Aname varchar(20),AContact no int,ACountry string)");
        System.out.println("Table is created"+i);
        con.close();
    }
    catch(SQLException e)
    {
        e.printStackTrace();
    }
}
}

【问题讨论】:

    标签: java mysql


    【解决方案1】:

    将 useSSL=false 放在名称数据库的末尾:

    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/INTtech?useSSL=false","root","root");
    

    【讨论】:

    • 我遇到了同样的错误,我在代码中添加了 useSSL=false 但它不起作用。您还有其他建议吗?
    • 虚假陈述是怎么写出来的。
    • Grlouk,确保您确实使用您配置的相同 URL 进行连接。
    • 此更改可以用于生产设置吗?
    • 如果存储的数据真的是私有的,不推荐。然后有必要生成一个证书来保护数据。
    猜你喜欢
    • 2023-03-13
    • 2017-02-03
    • 2017-11-25
    • 2018-10-06
    • 1970-01-01
    • 1970-01-01
    • 2020-12-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多