所以我使用服务器(google-app-engine)在客户端应用程序上进行身份验证。 当我使用JavaFX Webview或HttpsURLConnection时,一切都很顺利,但是当我使用HttpClient时它会连接它会引发以下错误
javax.net.ssl.SSLPeerUnverifiedException:peer未经过身份验证 at sun.security.ssl.SSLSessionImpl.getPeerCertificates(Unknown Source) 在org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128) at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:339) at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:123) 在org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:147) 在org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:108) 在org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415) 在org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641) 在org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576) 在org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
完整的ssl报告是 here
我正在使用的代码
System.out.println("I started");
String https_url = "https://app.quagrum.com";
URL url;
try {
url = new URL(https_url);
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();//Works
System.out.println("I ran?");
}
catch(Exception a)
{
}
try {
HttpGet get = new HttpGet("https://app.quagrum.com");
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(get);//Throws error
System.out.println(response.getStatusLine().getStatusCode());
if(response.getStatusLine().getStatusCode()!=200)
{
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
try {
Scanner s = new Scanner(instream).useDelimiter("\\A");
String result = s.hasNext() ? s.next() : "";
System.out.println(result);
result =result.substring(result.indexOf("\"",7));
result=result.substring(0, result.indexOf("\""));
System.out.println(result);
} finally {
instream.close();
}
}
}
}catch(Exception a)
{
a.printStackTrace();
}
}
答案 0 :(得分:0)
现在它正常运作。那个好的java让我完全重新设计了我程序的一部分然后让它在以后的版本中运行