本地网站连接本地mysql ,ssl是支持的不会报错
jdbc.url=jdbc:mysql://localhost:3306/ssm–crud?useUnicode=true&characterEncoding=UTF-8&useSSL=true
本地网站连接别的主机的mysql时,出现报错:
jdbc.url=jdbc:mysql://112.112.112.112:3306/ssm–crud?useUnicode=true&characterEncoding=UTF-8&useSSL=true
The last packet successfully received from the server was 764 milliseconds ago. The last packet sent successfully to the server was 757 milliseconds ago.] with root cause sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
mysql useSSL=true 问题,因为安装 mysql的时候,它会在本机 导入本机mysql的证书,所以可以使用 ssl 连接本机mysql。但是当本机网站需要连接到别的主机时,本机没有对方的ssl证书,所以就报错了。
解决办法就是:去掉 &useSSL=true
jdbc.url=jdbc:mysql://112.112.112.112:3306/ssm–crud?useUnicode=true&characterEncoding=UTF-8
Tue Nov 06 15:51:39 CST 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.