简体   繁体   English

使用Google Map API时获取“对等身份未通过身份验证”

[英]Getting “peer not authenticated” while using google map api's

I am getting "peer not authenticated" using google map api's after creating javafx package. 创建javafx包后,我使用Google Map api获得了“未对等身份验证”。 It is working fine when directly run from code or from executable jar file, The following is the exception I am getting, 从代码或可执行jar文件直接运行时,它工作正常,以下是我遇到的异常,

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)

I am using http client for calling the api. 我正在使用http客户端调用api。 I have tried bypassing the X509 certificate but still no luck 我尝试绕过X509证书,但仍然没有运气

below is my code 下面是我的代码

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());
            }

If by "creating javafx package" you mean creating a Self-Contained Application , then a reason for this is that the sun cryptography extensions are not included with the default self-contained application packaging as detailed in the JavaFX deployment blog . 如果通过“创建javafx程序包”表示创建一个自包含应用程序 ,则其原因是默认Java部署博客中未包含默认的自包含应用程序包装中的sun密码扩展。

Quoting from the deployment blog, there are instructions on including the sun jce provider with the self-contained application for JavaFX 2.2. 从部署博客引用,其中包含有关将sun jce提供程序与JavaFX 2.2的独立应用程序一起使用的说明。 Likely for future releases of the JavaFX deployment tools, a more convenient way will be provided to do this. 可能对于JavaFX部署工具的将来版本,将提供一种更方便的方法来执行此操作。

Fine tuning application bundle 微调应用程序包

If you are using packaging tools to produce an installable package there could be a need to tweak the application image before it is wrapped into the installer. 如果使用打包工具生成可安装的软件包,则可能需要先调整应用程序映像,然后再将其包装到安装程序中。 Why? 为什么? For example you may want to sign the application, so it does not appear to be untrusted to the OS (for example to please Mac OS X Gatekeeper). 例如,您可能需要对应用程序进行签名,因此它似乎并非不受操作系统的信任(例如,请取悦Mac OS X Gatekeeper)。

Also by default a self-contained application does not contain full copy of Java Runtime. 同样,默认情况下,独立的应用程序不包含Java Runtime的完整副本。 We only include set of mandatory components. 我们仅包括一组强制性组件。 Part of the reason why this approach was taken is that we want to reduce the package size. 采用这种方法的部分原因是我们希望减小包装尺寸。 However, there are situations where your application may depend on these optional components and in that case you will need a way to add them to the private runtime. 但是,在某些情况下,您的应用程序可能取决于这些可选组件,在这种情况下,您将需要一种将它们添加到私有运行时的方法。 For example https connections will not work if jre/lib/ext/sunjce_provider.jar is missing. 例如,如果缺少jre/lib/ext/sunjce_provider.jar则https连接将不起作用。

Currently this can be achieved by providing a custom config script that is executed after application image is populated. 当前,这可以通过提供自定义配置脚本来实现,该脚本在填充应用程序映像之后执行。 Like in the example above with the icon, you need to enable verbose output to find the name of the script file and then drop it to the location where packaging tools will find it. 像上面带有图标的示例一样,您需要启用详细输出以找到脚本文件的名称,然后将其拖放到打包工具可以找到它的位置。 Note that scripting language is platform specific too. 请注意,脚本语言也是特定于平台的。 Currently we only support shell for Mac/Linux and Windows Script on windows. 目前,我们仅支持Windows上的Mac / Linux和Windows脚本外壳。

How do you find out where the application image is located? 您如何找到应用程序映像的位置? Currently custom scripts are run in the directory where config files are stored but application image can be accessed using relative platform specific path. 当前,自定义脚本在存储配置文件的目录中运行,但是可以使用特定于平台的相对路径访问应用程序映像。 You can derive this path from verbose output or by setting environment variable JAVAFX_ANT_DEBUG to true to keep intermediate build artifacts. 您可以从详细输出中导出此路径,也可以通过将环境变量JAVAFX_ANT_DEBUG设置为true来保留中间构建工件。

Here is sample script (contributed by John Petersen) you can use to add jre/lib/ext/sunjce_provider.jar to the application package of MyApp on the Windows platform. 这是示例脚本(由John Petersen提供),可用于在Windows平台jre/lib/ext/sunjce_provider.jar到MyApp的应用程序包中。 Script using Javascript but you could also use VBScript for Windows scripting. 使用Java脚本的脚本,但是您也可以将VBScript用于Windows脚本。

<?xml version="1.0" ?>  
<package>  
   <job id="postImage">  
    <script language="JScript">  
     <![CDATA[  
        var oFSO = new ActiveXObject("Scripting.FileSystemObject");  
        var oFolder = oFSO.getFolder(".");  
        var from = oFolder.path + "\\MyApp\\app\\sunjce_provider.jar";  
        var to = oFolder.path + "\\MyApp\\runtime\\jre\\lib\\ext";  
        if (!oFSO.FolderExists(to)) {  
          oFSO.CreateFolder(to);  
        }  
        to += "\\";  
        oFSO.CopyFile(from, to);  
     ]]>  
    </script>  
   </job>  
</package>

I am using maven. 我正在使用Maven。 so how should i call this script from pom.xml that will create the jar within jre/lib/ext folder? 所以我应该如何从pom.xml调用此脚本,该脚本将在jre / lib / ext文件夹中创建jar?

I am not a maven expert. 我不是专家。 The solution above is for apache ant. 上面的解决方案是针对apache ant的。 You will need to work out your own solution to this issue if you wish to continue using maven. 如果您希望继续使用Maven,则需要解决此问题的解决方案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SSLPeerUnverifiedException:使用groovy的RestClient和ignoreSSLIssues()时“peer not authenticated” - SSLPeerUnverifiedException:“peer not authenticated” while using groovy's RestClient with ignoreSSLIssues() Jmeter 2.11:获取对等端未验证 - Jmeter 2.11 : Getting Peer Not Authenticated AWS S3对等方未经过身份验证 - AWS S3 peer not authenticated 在Amazon SQS上获取“对等未认证”异常 - Getting “peer not authenticated” exception on Amazon SQS 在 eclipse 中导入 Gradle 项目时,对等方未通过身份验证 - Peer not authenticated while importing Gradle project in eclipse 如何使用Java解决Rally Rest api中的javax.net.ssl.SSLPeerUnverifiedException:对等体未通过身份验证的异常? - How to solve javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated Exception in Rally Rest api using java? 通过JSON获取Google Latitude API中经过身份验证的用户的过去签入 - Getting past checkins of an authenticated user in Google latitude API via JSON 使用Google Map API v2时应用程序上出现黑屏 - Blank screen on application while using Google Map API v2 在Android中使用Google Map API时无法更新位置 - Not able to update location while using google map api in android 收到异常“ SSLPeerUnverifiedException:对等方未通过身份验证”,如何避免/忽略它? - Getting an exception “SSLPeerUnverifiedException: peer not authenticated”, how can I avoid/ignore it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM