java.net.SocketException:java.security.NoSuchAlgorithmException Java拒绝连接

时间:2015-11-26 00:17:00

标签: java eclipse ssl

我正在写一个工作计划,我已经被困这个问题了近一个星期了。无论我做什么,程序都会抛出相同的异常。

我查找了每个已知资源以及与此问题相关的每个问题,并且每次尝试和建议都失败了。根据我遇到的90%的帖子,它说我应该使用keytool将证书添加到我的keystore。这就是我的尝试:

keytool -import -alias abc -file ~/Downloads/\*.gcsip.nl   #=> gcsip.nl is the certificate I downloaded from the browser.

它问了我一个密码,我添加了它,当我运行它时我的应用程序仍然无效。我查看了“如何将证书导入Eclipse项目”,他们建议我执行相同的命令。我以前从未处理过Java证书,但它确实是一个真正的绝对噩梦。

奇怪的是,有一天应用程序运行得非常好,当我开始工作时,这个异常开始发生。我几乎什么都没改变。

我还研究了其他Caused by:例外情况,包括Invalid keystore format,也没有解决这个问题。老实说,即使仔细阅读了Oracle文档,我仍然不知道密钥库是什么,是什么,应该是什么样子。

我只是在找一个有过这个问题经验的人,他可以详细说明(比如我5岁)关于密钥库如何工作以及如何解决它。非常感谢任何帮助。

我应该注意到我不是很了解Java。

这是我的StackTrace:

java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
at javax.net.ssl.DefaultSSLSocketFactory.throwException(SSLSocketFactory.java:248)
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:255)
at sun.net.www.protocol.https.HttpsClient.createSocket(HttpsClient.java:409)
at sun.net.NetworkClient.doConnect(NetworkClient.java:162)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:275)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1104)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:998)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
at GCollect.authorize(GCollect.java:102)
at TestCase.main(TestCase.java:20)
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
    at java.security.Provider$Service.newInstance(Provider.java:1617)
    at sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
    at sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
    at javax.net.ssl.SSLContext.getInstance(SSLContext.java:156)
    at javax.net.ssl.SSLContext.getDefault(SSLContext.java:96)
    at javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:122)
    at javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory(HttpsURLConnection.java:332)
    at javax.net.ssl.HttpsURLConnection.<init>(HttpsURLConnection.java:289)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.<init>(HttpsURLConnectionImpl.java:85)
    at sun.net.www.protocol.https.Handler.openConnection(Handler.java:62)
    at sun.net.www.protocol.https.Handler.openConnection(Handler.java:57)
    at java.net.URL.openConnection(URL.java:972)
    at GCollect.authorize(GCollect.java:100)
    ... 1 more
    Caused by: java.io.IOException: Invalid keystore format
        at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:650)
        at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:55)
        at java.security.KeyStore.load(KeyStore.java:1445)
        at sun.security.ssl.TrustManagerFactoryImpl.getCacertsKeyStore(TrustManagerFactoryImpl.java:226)
        at sun.security.ssl.SSLContextImpl$DefaultSSLContext.getDefaultTrustManager(SSLContextImpl.java:767)
        at sun.security.ssl.SSLContextImpl$DefaultSSLContext.<init>(SSLContextImpl.java:733)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
        at java.security.Provider$Service.newInstance(Provider.java:1595)
        ... 13 more

0 个答案:

没有答案