我正在尝试使用reactor-netty
0.8.0.BUILD-SNAPSHOT版本创建对http / 2服务器的获取请求,但是我收到相同的错误
线程“ main”中的异常java.lang.NullPointerException在 反应器.netty.tcp.SslProvider。(SslProvider.java:309)在 reaction.netty.tcp.SslProvider $ Build.build(SslProvider.java:473)在 react..netty.tcp.TcpClientSecure.secure(TcpClientSecure.java:37)在 react..netty.tcp.TcpClient.secure(TcpClient.java:493)在 react.netty.http.client.HttpClientSecure.tcpConfiguration(HttpClientSecure.java:57) 在react.netty.http.client.HttpClient.request(HttpClient.java:573) 在react.netty.http.client.HttpClient.get(HttpClient.java:454) ApplicationKt.main(Application.kt:36)
我使用的Kotlin
代码如下
class Test
fun main(args: Array<String>) {
val trustManagerFactory: TrustManagerFactory =
TrustManagerFactory.getInstance("SunX509")
val trustStore: KeyStore = KeyStore.getInstance("JKS")
trustStore.load(Test::class.java.getResourceAsStream("MyClient.jks"),
"*************".toCharArray())
trustManagerFactory.init(trustStore)
val sslContext: SslContext = SslContextBuilder
.forClient()
.trustManager(trustManagerFactory)
.build()
val sslProviderBuilder: SslProvider.Builder = SslProvider
.builder()
.sslContext(sslContext)
ConnectionProvider.fixed("test", 1000)
HttpClient
.create(ConnectionProvider.fixed("test", 1000))
.secure { sslProviderBuilder }
.get()
.uri("https://localhost:8000/ping")
.response()
.block()
}