我正在尝试在 http4k 中使用双向 SSL 配置 Helidon Webserver。
以下是我的配置
class HelidonSsl(val port: Int = 8305) : ServerConfig {
override val stopMode = ServerConfig.StopMode.Immediate
override fun toServer(http: HttpHandler): Http4kServer {
val keystorePath = "keystore/ssl.keystore"
val keystorePassword = "changeit"
// Set up SSL/TLS configuration if keystore and truststore are present
val keyStoreKey = Keys.builder()
.keystore(
KeystoreKeys.builder()
.keystore(Resource.create(keystorePath))
.passphrase(keystorePassword)
.trustStore(true)
.build()
)
.build()
val tlsConfig = TlsConfig.builder()
.trustAll(true)
.privateKey(keyStoreKey)
.clientAuth(TlsClientAuth.OPTIONAL)
.build()
val server = WebServer.builder()
.tls(tlsConfig)
.port(port)
.build()
return object : Http4kServer {
override fun start() = apply { server.start() }
override fun stop() = apply { server.stop() }
override fun port(): Int = if (port != 0) port else server.port()
}
}
服务器启动,但建立连接时,我收到以下错误堆栈:
我已经查过了:
如果这是针对 Helidon 4,我建议您首先查看 https://github.com/helidon-io/helidon/tree/main/examples/webserver/mutual-tls 中的 MTLS 示例作为指导。对于 Helidon 3,它位于 https://github.com/helidon-io/helidon-examples/tree/helidon-3.x/examples/webserver/mutual-tls。