0
我有一個奇怪的問題與授權的SSL連接。首先,我創建了java類,它使用授權的ssl連接到外部服務器。我已經在命令行運行這個類,它工作正常,從外部服務器獲得所需的結果。在JSP頁面中使用此類之後。重新啓動後,我的tomcat JSP頁面也獲得了我想要的結果。但10-15請求JSP頁面給我這個錯誤:「javax.net.ssl.SSLHandshakeException:收到致命警報:handshake_failure」。在JSP頁面中沒有更多期望的結果。收到致命警報:JSP頁面handshake_failure錯誤
這裏是方法在Java類的代碼:
public String TransHttpsAuth(String server, String param, String method, String jksPath, String jksPass)
{
try
{
System.setProperty("javax.net.ssl.keyStoreType", "jks");
System.setProperty("javax.net.ssl.keyStore", jksPath);
System.setProperty("javax.net.ssl.keyStorePassword", jksPass);
server=server+"/?"+ param;
URL url = new URL(server);
HttpsURLConnection httpurlconnection = (HttpsURLConnection)url.openConnection();
httpurlconnection.setHostnameVerifier(new NullHostnameVerifier());
httpurlconnection.setRequestMethod(method);
httpurlconnection.setDoOutput(true);
httpurlconnection.connect();
InputStreamReader in = new InputStreamReader((InputStream) httpurlconnection.getContent());
BufferedReader buff = new BufferedReader(in);
String line = buff.readLine();
StringBuffer text = new StringBuffer();
while (line != null) {
text.append(line + "\n");
line = buff.readLine();
}
System.out.println(text.toString());
httpurlconnection.disconnect();
return text.toString();
}
catch(Exception exception)
{
return exception+"";
}
}
從JSP頁面調用:<% FSB FSB =新FSB(); (fsb.TransHttpsAuth(「https:// ext_server」,「prameters」,「GET」,「jks_path」,「password」)); %>
的Tomcat版本:6.0.32
Java版本:1.6.0_21