2016-11-08 95 views
0

我試圖從使用Java HTTP客戶端,像這樣的HTTPS服務器下載的圖像...收到致命警報:handshake_failure,調試不顯示故障原因

System.setProperty("javax.net.debug", "all"); 
System.setProperty("jsse.enableSNIExtension", "false"); 

URL url = new URL("https://secureserver.com/media/hot-jlaw-image.jpg") 
HttpURLConnection urlConn = url.openConnection() 
urlConn.setRequestMethod("GET") 

File myImg = new File("/Users/joe/Downloads/myImage.jpg") 
myImg.append(urlConn.getInputStream()) 

我的客戶是基於Java 8上運行隨着調試打開,我看到包括以下...

*** ClientHello, TLSv1.2 
RandomCookie: GMT: 1478629170 bytes = { 23, 147, 128, 164, 76, 36, 0, 143, 175, 43, 227, 154, 16, 212, 209, 112, 224, 227, 0, 109, 196, 178, 231, 43, 112, 198, 36, 235 } 
Session ID: {} 
Cipher Suites: [TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV] 

main, WRITE: TLSv1.2 Handshake, length = 193 

Caught: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure 
[Raw read]: length = 5 
0000: 15 03 03 00 02          ..... 
[Raw read]: length = 2 
0000: 02 28            .(
main, READ: TLSv1.2 Alert, length = 2 
main, RECV TLSv1.2 ALERT: fatal, handshake_failure 

所以好像客戶端Hello發送和握手被髮送,但沒有從服務器發回關於除外握手失敗警報。

This answer提出了導致此錯誤可能發生的幾個原因,例如不兼容的密碼套件或不完整的信任路徑,並且建議開啓調試。

但在我的情況下,調試還沒有透露罪魁禍首。任何建議還有什麼要嘗試?

+0

它是自簽名證書嗎? –

+0

我看到服務器的根CA是Starfield Services根證書頒發機構 - G2,難道我的Java客戶端不能識別此CA? – AbuMariam

回答

0

原來,問題是這條線

System.setProperty("jsse.enableSNIExtension", "false");' 

他們的服務器一定是虛擬,因爲some posts表示這不會對這樣的服務器上工作。

相關問題