我有一个旧项目,试图修复其中的错误。有这样的代码(我仍然不完全了解其含义):
SslContext sslCtx = SslContextBuilder
.forClient()
.trustManager(
new FingerprintTrustManagerFactory(
mySSLCertificate
)
).build();
我正在尝试获取sslcontext,但是会定期发生错误:
javax.net.ssl.SSLException: failed to
initialize the client-side SSL context
at io.netty.handler.ssl.JdkSslClientContext.newSSLContext(JdkSslClientContext.java:296)
at io.netty.handler.ssl.JdkSslClientContext.<init>(JdkSslClientContext.java:264)
at io.netty.handler.ssl.SslContext.newClientContextInternal(SslContext.java:739)
at io.netty.handler.ssl.SslContextBuilder.build(SslContextBuilder.java:319)
at com.kbl.kbl.network.netty.NettyClient.<init>(NettyClient.java:47)
at com.kbl.kbl.network.NetworkService$2.run(NetworkService.java:189)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'javax.net.ssl.TrustManager[]
io.netty.handler.ssl.util.SimpleTrustManagerFactory.engineGetTrustManagers()'
on a null object reference
at io.netty.handler.ssl.util.SimpleTrustManagerFactory$SimpleTrustManagerFactorySpi.engineGetTrustManagers(SimpleTrustManagerFactory.java:131)
at javax.net.ssl.TrustManagerFactory.getTrustManagers(TrustManagerFactory.java:301)
at io.netty.handler.ssl.JdkSslClientContext.newSSLContext(JdkSslClientContext.java:280)
at io.netty.handler.ssl.JdkSslClientContext.<init>(JdkSslClientContext.java:264)
at io.netty.handler.ssl.SslContext.newClientContextInternal(SslContext.java:739)
at io.netty.handler.ssl.SslContextBuilder.build(SslContextBuilder.java:319)
at com.kbl.kbl.network.netty.NettyClient.<init>(NettyClient.java:47)
at com.kbl.kbl.network.NetworkService$2.run(NetworkService.java:189)
at java.lang.Thread.run(Thread.java:764)
如何解决?在哪里挖?