JDK安全證書一個錯誤訊息 No subject alternative names present
我使用Java消費某網站一個Restful API時,遇到這個錯誤:
21:31:16.383 [main] DEBUG org.springframework.web.client.RestTemplate - Created GET request for " "
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 " ": 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.(HttpsClient.java:559)
at sun.net.(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.(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
錯誤的核心就一句: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區域能看到IP地址:
之後原始的錯誤就消失了:
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2668581/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SSL - SSLHandshakeException: No subject alternative names presentException
- 【java細節】Java程式碼忽略https證照:No subject alternative names presentJavaHTTP
- SSL - SSLHandshakeException: No subject alternative names matching IP address foundException
- Laravel 的 Validation 檢索驗證錯誤訊息Laravel
- Angular No provider for EffectsRootModule錯誤訊息AngularIDE
- SAP錯誤訊息除錯之七種武器:讓所有的錯誤訊息都能被定位除錯
- 如何處理錯誤訊息PleaseinstalltheLinuxkernelheaderfilesLinuxHeader
- 公司網站證書錯誤怎麼解決,快速排除公司網站SSL證書錯誤網站
- Angular 伺服器端渲染應用的一個錯誤訊息 - localStorage is not definedAngular伺服器
- Request 驗證錯誤沒有返回錯誤資訊?
- python 用traceback列印錯誤訊息(轉)Python
- 什麼是好的錯誤訊息?
- 錯誤訊息sales area is not assigned for the header productHeader
- Angular 錯誤訊息:ERROR Error NullInjectorError No provider for XXAngularErrorNullIDE
- Laravel 5.5 Validator 自定義錯誤返回訊息Laravel
- SSL證書是一個域名一個證書嗎?多個域名能用一張SSL證書嗎?
- 顯示驗證的錯誤資訊
- 2024.11.1 一個錯誤
- jQuery Validate自定義驗證錯誤資訊jQuery
- 使用 Spring Boot 提供API錯誤訊息的好方式Spring BootAPI
- SAP Spartacus RouterModule.forRoot() called twice 的錯誤訊息
- 寶塔安裝證書後http訪問錯誤HTTP
- 大多數 SSL 證書籤發錯誤的主要原因是軟體錯誤
- 修改網站後提示證書錯誤,解決SSL證書問題的全面指南網站
- 一聲嘆息,jdk竟然有4個randomJDKrandom
- 使用 acme 指令碼給專案新增 https 證書排查錯誤一例ACM指令碼HTTP
- 程式碼安全測試第二十六期:透過錯誤訊息導致的資訊暴露
- 使用表單驗證,建立資料驗證層,Ajax 統一返回驗證錯誤資訊
- 如何根據 SAP UI5 框架程式碼丟擲的錯誤訊息,反查出是哪一行程式碼引起的錯誤訊息試讀版UI框架行程
- 關於錯誤訊息 RangeError - Maximum call stack size exceeded at XXXError
- Angular 依賴注入錯誤訊息:ERROR Error NullInjectorError No provider for XXAngular依賴注入ErrorNullIDE
- SAP HANA 錯誤訊息 SYS_XSA authentication failed SQLSTATE - 28000AISQL
- cypress 的錯誤訊息 - the element has become detached or removed from the domREM
- 如何處理錯誤訊息Please install the Linux kernel header filesLinuxHeader
- 如何處理錯誤訊息Please install the gcc make perl packagesGCPackage
- 如何處理Docker錯誤訊息:please add——insecure-registryDocker
- SSL證書7大常見錯誤及解決方法!
- 使用nslookup檢視SSL安全證書域名驗證資訊