初始化默认SSL上下文失败 [英] Failure initializing default SSL context

查看:802
本文介绍了初始化默认SSL上下文失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的httpclient项目遇到了一个奇怪的问题。在其他两个带有java1.6的Centos系统中运行成功。但它在另一台机器上失败了(centos和java1.6)。问题是:

my httpclient project has encountered a strange problem .it run successful in other two Centos systems with java1.6. but it failed in another machine(centos and java1.6). the problem is:


java.lang.IllegalStateException: Failure initializing default SSL context
     [java]    at org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext(SSLSocketFactory.java:211)
     [java]    at org.apache.http.conn.ssl.SSLSocketFactory.(SSLSocketFactory.java:333)
     [java]    at org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory(SSLSocketFactory.java:165)
     [java]    at org.apache.http.impl.conn.SchemeRegistryFactory.createDefault(SchemeRegistryFactory.java:45)
     [java]    at org.apache.http.impl.client.AbstractHttpClient.createClientConnectionManager(AbstractHttpClient.java:294)
     [java]    at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:445)
     [java]    at simulativeLogin.WebClientDevWrapper.wrapClient(Unknown Source)
     [java]    at simulativeLogin.GetAccessToken.getToken(Unknown Source)
     [java]    at crawler.FriendshipCrawler.main(Unknown Source)
     [java]    at java.lang.reflect.Method.invoke(libgcj.so.10)
     [java]    at org.apache.tools.ant.taskdefs.ExecuteJava.run(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.taskdefs.Java.run(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.taskdefs.Java.executeJava(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.taskdefs.Java.executeJava(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.taskdefs.Java.execute(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.UnknownElement.execute(ant-1.7.1.jar.so)
     [java]    at java.lang.reflect.Method.invoke(libgcj.so.10)
     [java]    at org.apache.tools.ant.dispatch.DispatchUtils.execute(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.Task.perform(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.Target.execute(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.Target.performTasks(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.Project.executeSortedTargets(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.Project.executeTarget(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.Project.executeTargets(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.Main.runBuild(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.Main.startAnt(ant-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.launch.Launcher.run(ant-launcher-1.7.1.jar.so)
     [java]    at org.apache.tools.ant.launch.Launcher.main(ant-launcher-1.7.1.jar.so)
     [java] Caused by: java.lang.IllegalStateException
     [java]    at gnu.javax.net.ssl.provider.X509KeyManagerFactory.engineGetKeyManagers(libgcj.so.10)
     [java]    at javax.net.ssl.KeyManagerFactory.getKeyManagers(libgcj.so.10)
     [java]    at org.apache.http.conn.ssl.SSLSocketFactory.createSSLContext(SSLSocketFactory.java:187)
     [java]    at org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext(SSLSocketFactory.java:209)


推荐答案

这不是你的错。使用另一个JVM,它将解决您的问题。我有同样的问题。我在Gumstix / linux / jamVM上运行Apache HttpClient。我得到了完全相同的例外。这是X509的测试程序。我在我的Mac mini上运行它,结果是SunX509作为算法;但是在jamVM上,它是'null'。试试吧。

It's not your fault. Use another JVM, that will solve your problem. I had the same problem. I'm running Apache HttpClient on Gumstix/linux/jamVM. I got the exactly the same exceptions. Here is a test program for X509. I ran it on my Mac mini, the result is "SunX509" as algorithm; but on jamVM, it is 'null'. Try it.

public class TestX509 {
    public static void main(String[] args) {
        String algorithm = Security
            .getProperty("ssl.KeyManagerFactory.algorithm");

        System.out.println("algorithm is " + algorithm);
    }
}

参见gnu.javax.net第108行的来源.ssl.provider.X509KeyManagerFactory.java。这是异常的来源。 (因为'current'是一个密钥管理器,它是null。你知道从上一个测试开始。)

See source of line 108 of gnu.javax.net.ssl.provider.X509KeyManagerFactory.java. This is where the exception comes from. (Because the 'current' is a key manager, which is null. You know that from the previous test.)

104:   protected KeyManager[] engineGetKeyManagers()
105:   {
106:     if (current == null)
107:       {
108:         throw new IllegalStateException();
109:       }
110:     return new KeyManager[] { current };
111:   }
112:

由于库抛出IllegalStateException,这是一个RuntimeException,有人认为它是GCJ的一个bug,并在此处报告 http ://code.google.com/p/selenium/issues/detail?id = 2483

Since the library throws IllegalStateException, which is a RuntimeException, some one considered it as a bug of GCJ and reported it here http://code.google.com/p/selenium/issues/detail?id=2483.

这篇关于初始化默认SSL上下文失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆