Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring启动应用程序(使用mybatis)在引入CA签名证书后停止连接mysql_Java_Mysql_Spring Boot_Ssl_Mybatis - Fatal编程技术网

Java Spring启动应用程序(使用mybatis)在引入CA签名证书后停止连接mysql

Java Spring启动应用程序(使用mybatis)在引入CA签名证书后停止连接mysql,java,mysql,spring-boot,ssl,mybatis,Java,Mysql,Spring Boot,Ssl,Mybatis,大约一周前,开发环境(AWS EC2实例)中的一个spring引导应用程序突然停止了连接,该应用程序在此之前使用SSL成功连接到MySql。以下是从无用堆栈跟踪中选择的内容: ### Error querying database. Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet sent successfully to the s

大约一周前,开发环境(AWS EC2实例)中的一个spring引导应用程序突然停止了连接,该应用程序在此之前使用SSL成功连接到MySql。以下是从无用堆栈跟踪中选择的内容:

### Error querying database.  Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
### The error may exist in com/domain/app/data/mybatis/mappers/SomeMapper.xml
### The error may involve com.domain.app.data.mybatis.mappers.SomeMapper.getUserByUsername
### The error occurred while executing a query
### Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:76)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:93)
    at com.sun.proxy.$Proxy91.getUserByUsername(Unknown Source)
    at com.domain.app.security.SomeService.loadUserByUsername(SomeService.java:32)
    at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:108)
    ... 96 more
Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

...
Caused by: java.net.ConnectException: Connection timed out (Connection timed out)
一些事实:

  • 当从我的本地计算机运行时,完全相同的应用程序构建工作(具有相同的db连接信息)。可能排除了配置错误的应用程序代码
  • mysql驻留在一个单独的EC2实例上,我可以通过“故障”EC2实例上的CLI连接到mysql。可能排除了安全/ACL问题
  • 连接字符串的形式如下:jdbc:mysql://x.x.x.x:3306/db_name?useSSL=true&verifyServerCertificate=true&requireSSL=true&autoReconnect=true,{db username},{db password}。同样,这个字符串在我自己的机器上使用时可以工作
  • 大约两周前,CA签署的ssl证书被添加到java密钥库中的spring boot应用程序中。相同的证书没有添加到mysql,mysql使用的是自生成和自签名的证书。有一个很小的,几乎不可信的机会,应用程序没有在有故障的环境中测试过,尽管我很确定我从那时起就使用过这个环境
我目前的想法是,dev应用程序中的新证书可能以某种方式与mysql的自生成和自签名证书发生冲突,这种情况在我的机器上可能不会发生。但我不知道从哪里开始验证或测试这个理论

我已经对此进行了大约7个小时的故障排除,包括谷歌搜索,以及阅读了许多相关问题的回复。如果有人以我不理解的方式回答了这个问题,我表示歉意

你们中有谁能给我指出一些答案或疑难解答