就出現以下異常:
javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name
at sun.security.ssl.ClientHandshaker.handshakeAlert(ClientHandshaker.java:1292)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1952)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1077)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at com.mymap.model.CaptureJavascript.getPosition(CaptureJavascript.java:60)
嘗試照網上說的添加: **System.setProperty("jsse.enableSNIExtension", "false");**
但是無效。
以下是我的代碼。該方法在Capture類中,servlet類中調用Capture類的方法,方法代碼如下:
private double[] getPosition(double lat, double lon) throws Exception
{
System.setProperty("jsse.enableSNIExtension", "false");
String strURL = "https://eosweb.larc.nasa.gov/cgi-bin/sse/grid.cgi?&num=230000&lat=" + lat +
"&submit=Submit&veg=17&p=swv_dwn&step=2&lon=" + lon;
//"https://eosweb.larc.nasa.gov/cgi-bin/sse/grid.cgi?&num=199997&lat=" + lat + "&submit=Submit&veg=17&p=swv_dwn&step=2&lon=" + lon;
URL url = new URL(strURL);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
InputStreamReader input = new InputStreamReader(httpConn.getInputStream(), "utf-8");
BufferedReader bufReader = new BufferedReader(input);
StringBuilder contentBuf = new StringBuilder();
String line = "";
while((line = bufReader.readLine()) != null) {
contentBuf.append(line);
}
String buf = contentBuf.toString();
int beginIx = buf.indexOf("year Average");
int endIx = buf.indexOf("Minimum And Maximum Difference");
String resultstr = buf.substring(beginIx, endIx);
return getDoubles(resultstr);
}
http://demo.netfoucs.com/will_awoke/article/details/38587467
看樓主看一下把,不知道能解決你的問題不能