Spring Boot: Jdbc javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify

前端 未结 10 1200
青春惊慌失措
青春惊慌失措 2021-02-02 08:59

I am currently learning more about implementing JDBC and using databases in a Spring Boot webapp, and I encountered the following Stack Trace written in the bottom of the post.<

相关标签:
10条回答
  • 2021-02-02 09:24

    I also faced the same issue. if you look the the stacktrace, it's cleary mentioned what to do -

    Sat Mar 16 09:00:01 IST 2019 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.
    

    so after disabling the ssl by making changes in data source url solved the problem -

    spring.datasource.url=jdbc:mysql://localhost:3306/security?useSSL=false
    
    0 讨论(0)
  • 2021-02-02 09:24

    I faced a similar issue when I upgraded the Java version in my server to 11 from 8.

    The spring boot started supporting Java 11 from 2.1 and onwards. So make sure your project's dependencies are also updated accordingly. This is relevant for this answer as SpringBoot also influence MySQL connector, Hibernate core, and other dependencies.

    The inability to connect to DB was resulting in some more NoClassDefFoundErrors. So make sure you solve this first before looking into other errors.

    An example pom dependency for the SpringBoot starter

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.12.RELEASE</version>
        <relativePath />
    </parent>
    

    Hope this helps someone.

    0 讨论(0)
  • 2021-02-02 09:30

    The warning looks like a MySQL driver bug with Java 11 and SSL enabled : https://bugs.mysql.com/bug.php?id=93590
    Deactivating encryption because of a driver warning is a bad idea.

    Your insertion problem looks more like a classic transaction issue though, I doubt it is related to the SSL warning.

    0 讨论(0)
  • 2021-02-02 09:30

    This Worked for me

       <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
            <version>8.0.20</version>
        </dependency>
    
    0 讨论(0)
  • 2021-02-02 09:32

    I had this issue and decided to use Carrier Pigeon Protocol's solution until I accidentally solved it by updating Tomcat from version 9.0.12 to 9.0.16.

    0 讨论(0)
  • 2021-02-02 09:34

    To solve this problem, it took me about three days.

    (Edit: This is a workaround for testing and not actually a solution.)

    At first, I started solving the problem from trying to configure my own SSL for mysql, and I spent quite a few hours on that. Too much time had passed until I realized configuring it had to do with Cmake and C++, which made me give up. It was very frustrating. However I did not give up and tried to disable SSL entirely through a method that hasn't been found. And I eventually did find the method. Here it is:

    1. You have to use the legacy password for MySQL. The legacy password is the way MySQL authenticated things in version 5.7x.

    Open up the MySQL installer again, and reconfigure the MySQL Server settings. When you get there you will see this screen:

    The screen that you should get to

    You might get some errors when reaching the final stage of the reconfiguration:

    I had problems at the final stage I had no idea how to fix so I uninstalled MySQL altogether. I use windows. I deleted the MySQL project root directory from Program Files to uninstall MySQL. I also deleted the databases saved in Program Data (a hidden folder in the C Drive) because I wanted to start afresh(WARNING: this will delete all your previously saved data!). Uninstalling MySQL from the control panel might not be enough to completely erase MySQL from your computer.

    1. Delete all *.pem files in C:\ProgramData\MySQL\MySQL Server 8.0\Data. (or move it somewhere else, which is what I did)

    You might not see ProgramData in the C Drive. That is because it is a hidden folder. In order to see hidden folders:

    search for folder options in the control panel.

    Go to view.

    Under 'Advanced settings' and under 'Hidden files and folders' of that, click "Show hidden files, folders, and drives."

    1. Go to C:\ProgramData\MySQL\MySQL Server 8.0 and open my.cnf (or my.ini). Add the following line after [mysqld]:

    ssl=0

    Then save. It should work now.

    References:

    1. https://community.atlassian.com/t5/Confluence-questions/MySQL-Public-Key-Retrieval-is-not-allowed/qaq-p/778956
    2. https://scalegrid.io/blog/configuring-and-managing-ssl-on-your-mysql-server/
    0 讨论(0)
提交回复
热议问题