我在創建javafx包後使用google map api獲取「peer not authenticated」。 它工作正常時,直接從代碼或可執行的JAR文件運行,以下是例外,我得到,在使用google map api的時候獲取「peer not authenticated」
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:397)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:390)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:561)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
at com.precisionhawk.flightplanner.utils.LocationUtils.performAPICall(LocationUtils.java:109)
at com.precisionhawk.flightplanner.utils.LocationUtils.getAutocompleteResults(LocationUtils.java:74)
at com.precisionhawk.flightplanner.controls.AddressTextField$1$1.run(AddressTextField.java:103)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
我使用HTTP客戶端調用API。我曾試圖通過「創建JavaFX的包」繞過X509證書,但仍沒有運氣
下面是我的代碼
SSLContext ctx = null;
try {
SSLUtilities.trustAllHostnames();
SSLUtilities.trustAllHttpsCertificates();
HttpClient httpClient = new DefaultHttpClient();
HttpGet getRequest = new HttpGet(url.toString());
getRequest.addHeader("accept", "application/json");
HttpResponse response = httpClient.execute(getRequest);
if (response.getStatusLine().getStatusCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatusLine().getStatusCode());
}
BufferedReader br = new BufferedReader(
new InputStreamReader((response.getEntity().getContent())));
String inputLine;
while ((inputLine = br.readLine()) != null) {
result = result + inputLine;
}
br.close();
LOG.info("Autocomplete API call Response: " + result);
}
catch (Exception e) {
LOG.error("Autocomplete Exception: "+e.getMessage());
}
我正在使用maven。所以我應該如何從pom.xml中調用這個腳本來創建jre/lib/ext文件夾中的jar? – PDP 2013-05-06 05:40:34