socketpair java_SSLSocket创建中的Java异常

在代码中:

System.setProperty("javax.net.ssl.trustStore", cacerts);

System.setProperty("javax.net.ssl.trustStorePassword", pwdCacerts);

SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();

SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket("localhost", port);

我得到一个Java异常:

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(Unknown Source)

at javax.net.ssl.DefaultSSLSocketFactory.createSocket(Unknown Source)

at PracticaRO.Cliente.main(Cliente.java:24)

Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)

at java.security.Provider$Service.newInstance(Unknown Source)

at sun.security.jca.GetInstance.getInstance(Unknown Source)

at sun.security.jca.GetInstance.getInstance(Unknown Source)

at javax.net.ssl.SSLContext.getInstance(Unknown Source)

at javax.net.ssl.SSLContext.getDefault(Unknown Source)

at javax.net.ssl.SSLSocketFactory.getDefault(Unknown Source)

at PracticaRO.Cliente.main(Cliente.java:23)

Caused by: java.io.IOException: Invalid keystore format

at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source)

at sun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source)

at java.security.KeyStore.load(Unknown Source)

at sun.security.ssl.TrustManagerFactoryImpl.getCacertsKeyStore(Unknown Source)

at sun.security.ssl.SSLContextImpl$DefaultSSLContext.getDefaultTrustManager(Unknown Source)

at sun.security.ssl.SSLContextImpl$DefaultSSLContext.(Unknown Source)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

... 7 more

在我使用-keytool -import -keystore cacerts -alias kpServer类型JCEKS -file Server.cer将新的公钥导入cacerts之前,它一直工作良好,是什么导致了上述异常.

在此先感谢您的帮助.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值