真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

如何解決JDK安全證書錯(cuò)誤消息Nosubjectalternativenamespresent問題

小編給大家分享一下如何解決JDK安全證書錯(cuò)誤消息No subject alternative names present問題,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

創(chuàng)新互聯(lián)2013年開創(chuàng)至今,先為萬全等服務(wù)建站,萬全等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為萬全企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

我使用Java消費(fèi)某網(wǎng)站一個(gè)Restful API時(shí),遇到這個(gè)錯(cuò)誤:

21:31:16.383 [main] DEBUG org.springframework.web.client.RestTemplate - Created GET request for " https://127.0.0.1:5031/commerce/product"
21:31:16.388 [main] DEBUG org.springframework.web.client.RestTemplate - Setting request Accept header to [text/plain, application/json, application/*+json, /]
Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on GET request for " https://127.0.0.1:5031/commerce/product": java.security.cert.CertificateException: No subject alternative names present; nested exception is  javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:673)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:620)
at org.springframework.web.client.RestTemplate.getForEntity(RestTemplate.java:319)
at com.sap.prolikeService.service.impl.CommerceProductService.getProductDetailByID(CommerceProductService.java:23)
at com.sap.prolikeService.sandbox.SandboxTest.getProductDetailTest(SandboxTest.java:45)
at com.sap.prolikeService.sandbox.SandboxTest.main(SandboxTest.java:49)
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1506)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at  sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at  sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at  sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:78)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:659)
... 5 more
Caused by: java.security.cert.CertificateException: No subject alternative names present
at sun.security.util.HostnameChecker.matchIP(HostnameChecker.java:144)
at sun.security.util.HostnameChecker.match(HostnameChecker.java:93)
at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455)
at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:436)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:200)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1488)
... 19 more

錯(cuò)誤的核心就一句:No subject alternative names present

如何解決JDK安全證書錯(cuò)誤消息No subject alternative names present問題

解決方案:重新生成證書,將缺失的IP地址包含在證書的extension部分即可。命令行如下:

keytool -genkey -alias tomcat2 -keyalg RSA -keystore ./jerry2.keystore -ext SAN=DNS:test.abc.com,ip:127.0.0.1

證書生成后,在Subject Alternative names區(qū)域能看到IP地址:

如何解決JDK安全證書錯(cuò)誤消息No subject alternative names present問題

之后原始的錯(cuò)誤就消失了:

如何解決JDK安全證書錯(cuò)誤消息No subject alternative names present問題

以上是“如何解決JDK安全證書錯(cuò)誤消息No subject alternative names present問題”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!


本文名稱:如何解決JDK安全證書錯(cuò)誤消息Nosubjectalternativenamespresent問題
分享URL:http://weahome.cn/article/psisgh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部