基于【 bug解决】一 || Springboot整合mqtt协议导致的错误

目录

1、报错信息如下所示:

by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No name matching XXX found

org.eclipse.paho.client.mqttv3.MqttException: MqttException
	at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38) ~[org.eclipse.paho.client.mqttv3-1.2.2.jar:na]
	at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:736) ~[org.eclipse.paho.client.mqttv3-1.2.2.jar:na]
	at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_251]
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No name matching XXX found
	at sun.security.ssl.Alerts.getSSLException(Alerts.java:198) ~[na:1.8.0_251]
	at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1967) ~[na:1.8.0_251]
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:331) ~[na:1.8.0_251]
	at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:325) ~[na:1.8.0_251]
	at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1689) ~[na:1.8.0_251]
	at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:226) ~[na:1.8.0_251]
	at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1082) ~[na:1.8.0_251]
	at sun.security.ssl.Handshaker.process_record(Handshaker.java:1010) ~[na:1.8.0_251]
	at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1079) ~[na:1.8.0_251]
	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1388) ~[na:1.8.0_251]
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1416) ~[na:1.8.0_251]
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1400) ~[na:1.8.0_251]
	at org.eclipse.paho.client.mqttv3.internal.SSLNetworkModule.start(SSLNetworkModule.java:149) ~[org.eclipse.paho.client.mqttv3-1.2.2.jar:na]
	at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:722) ~[org.eclipse.paho.client.mqttv3-1.2.2.jar:na]
	... 1 common frames omitted
Caused by: java.security.cert.CertificateException: No name matching sgacc.agrithings.cn found
	at sun.security.util.HostnameChecker.matchDNS(HostnameChecker.java:231) ~[na:1.8.0_251]
	at sun.security.util.HostnameChecker.match(HostnameChecker.java:96) ~[na:1.8.0_251]
	at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:459) ~[na:1.8.0_251]
	at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:427) ~[na:1.8.0_251]
	at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:232) ~[na:1.8.0_251]
	at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132) ~[na:1.8.0_251]
	at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1671) ~[na:1.8.0_251]
	... 10 common frames omitted

百度上所有的解决方案都试了,最终发现是springboot版本导致的,测试了2.2.7和2.3.0版本,都报以上错误信息,改为2.2.4以下版本后正常。

哪位大佬知道是什么原因导致的麻烦评论区回复下,非常感谢!

上一篇:R语言报错:Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : n行没有x元素


下一篇:解決 Elasticsearch 使用 Java High Level REST Client 時出現 NoClassDefFoundError 錯誤