Skip to content

Commit

Permalink
Use TlsProvider in ArmeriaServerBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
danicheg committed Nov 14, 2024
1 parent 6ae7cf4 commit a60c24a
Showing 1 changed file with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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`.
Expand All @@ -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())
}
}
})
Expand All @@ -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]].
Expand Down

0 comments on commit a60c24a

Please sign in to comment.