From a60c24af053ea04898b8ba02968eb73d23a6887b Mon Sep 17 00:00:00 2001 From: danicheg Date: Thu, 14 Nov 2024 20:47:55 +0300 Subject: [PATCH] Use TlsProvider in ArmeriaServerBuilder --- .../armeria/server/ArmeriaServerBuilder.scala | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/server/src/main/scala/org/http4s/armeria/server/ArmeriaServerBuilder.scala b/server/src/main/scala/org/http4s/armeria/server/ArmeriaServerBuilder.scala index 7df5035..7b35628 100644 --- a/server/src/main/scala/org/http4s/armeria/server/ArmeriaServerBuilder.scala +++ b/server/src/main/scala/org/http4s/armeria/server/ArmeriaServerBuilder.scala @@ -21,7 +21,13 @@ import cats.syntax.applicative._ import cats.syntax.flatMap._ import cats.syntax.functor._ import com.linecorp.armeria.common.util.Version -import com.linecorp.armeria.common.{HttpRequest, HttpResponse, SessionProtocol} +import com.linecorp.armeria.common.{ + HttpRequest, + HttpResponse, + SessionProtocol, + TlsKeyPair, + TlsProvider +} import com.linecorp.armeria.server.{ HttpService, HttpServiceWithRoutes, @@ -247,7 +253,12 @@ sealed class ArmeriaServerBuilder[F[_]] private ( * [[withTlsCustomizer]] */ def withTls(keyCertChainFile: File, keyFile: File, keyPassword: Option[String]): Self = - atBuild(_.tls(keyCertChainFile, keyFile, keyPassword.orNull)) + atBuild( + _.tlsProvider( + TlsProvider + .builder() + .keyPair(TlsKeyPair.of(keyFile, keyPassword.orNull, keyCertChainFile)) + .build())) /** Configures SSL or TLS of this [[com.linecorp.armeria.server.Server]] with the specified * `keyCertChainInputStream`, `keyInputStream` and `keyPassword`. @@ -265,7 +276,11 @@ sealed class ArmeriaServerBuilder[F[_]] private ( .both(keyInputStream) .use { case (keyCertChain, key) => F.delay { - ab.tls(keyCertChain, key, keyPassword.orNull) + ab.tlsProvider( + TlsProvider + .builder() + .keyPair(TlsKeyPair.of(key, keyPassword.orNull, keyCertChain)) + .build()) } } }) @@ -277,7 +292,12 @@ sealed class ArmeriaServerBuilder[F[_]] private ( * [[withTlsCustomizer]] */ def withTls(key: PrivateKey, keyCertChain: X509Certificate*): Self = - atBuild(_.tls(key, keyCertChain: _*)) + atBuild( + _.tlsProvider( + TlsProvider + .builder() + .keyPair(TlsKeyPair.of(key, keyCertChain: _*)) + .build())) /** Configures SSL or TLS of this [[com.linecorp.armeria.server.Server]] with the specified * [[javax.net.ssl.KeyManagerFactory]].