Skip to content

Commit

Permalink
chore: Migration for dropped AkkaSSLConfig, additional dropped privat…
Browse files Browse the repository at this point in the history
…e methods (#32071)
  • Loading branch information
johanandren authored Sep 1, 2023
1 parent d21fd6e commit 997068c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ Cluster client has been deprecated since Akka 2.6.0 (2019-11-06). Details on how

The old "Typed Actor" API (`akka.actor.TypedActor`) has been deprecated since Akka 2.6.0 (2019-11-06) and has been dropped.
No detailed migration guide exists, the recommendation is to move to the new Akka Typed APIs.

## Akka SSLConfig

The Akka SSLConfig convenience and methods accepting it has been deprecated since Akka 2.6.0 and has been dropped.
Usage should be replaced with directly creating a `javax.net.ssl.SSLEngine` using the JDK APIs.
12 changes: 6 additions & 6 deletions akka-stream/src/main/scala/akka/stream/impl/io/TLSActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import akka.util.ByteString

def props(
maxInputBufferSize: Int,
createSSLEngine: ActorSystem => SSLEngine, // ActorSystem is only needed to support the AkkaSSLConfig legacy, see #21753
verifySession: (ActorSystem, SSLSession) => Try[Unit], // ActorSystem is only needed to support the AkkaSSLConfig legacy, see #21753
createSSLEngine: () => SSLEngine,
verifySession: SSLSession => Try[Unit],
closing: TLSClosing,
tracing: Boolean = false): Props =
Props(new TLSActor(maxInputBufferSize, createSSLEngine, verifySession, closing, tracing)).withDeploy(Deploy.local)
Expand All @@ -50,8 +50,8 @@ import akka.util.ByteString
*/
@InternalApi private[stream] class TLSActor(
maxInputBufferSize: Int,
createSSLEngine: ActorSystem => SSLEngine, // ActorSystem is only needed to support the AkkaSSLConfig legacy, see #21753
verifySession: (ActorSystem, SSLSession) => Try[Unit], // ActorSystem is only needed to support the AkkaSSLConfig legacy, see #21753
createSSLEngine: () => SSLEngine,
verifySession: SSLSession => Try[Unit],
closing: TLSClosing,
tracing: Boolean)
extends Actor
Expand Down Expand Up @@ -161,7 +161,7 @@ import akka.util.ByteString
// The engine could also be instantiated in ActorMaterializerImpl but if creation fails
// during materialization it would be worse than failing later on.
val engine =
try createSSLEngine(context.system)
try createSSLEngine()
catch { case NonFatal(ex) => fail(ex, closeTransport = true); throw ex }

engine.beginHandshake()
Expand Down Expand Up @@ -466,7 +466,7 @@ import akka.util.ByteString
if (tracing) log.debug("handshake finished")
val session = engine.getSession

verifySession(context.system, session) match {
verifySession(session) match {
case Success(()) =>
currentSession = session
corkUser = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import javax.net.ssl.{ SSLEngine, SSLSession }
import scala.util.Try

import akka.NotUsed
import akka.actor.ActorSystem
import akka.annotation.InternalApi
import akka.stream._
import akka.stream.TLSProtocol._
Expand All @@ -27,8 +26,8 @@ import akka.util.ByteString
cipherOut: Outlet[ByteString],
shape: BidiShape[SslTlsOutbound, ByteString, ByteString, SslTlsInbound],
attributes: Attributes,
createSSLEngine: ActorSystem => SSLEngine, // ActorSystem is only needed to support the AkkaSSLConfig legacy, see #21753
verifySession: (ActorSystem, SSLSession) => Try[Unit], // ActorSystem is only needed to support the AkkaSSLConfig legacy, see #21753
createSSLEngine: () => SSLEngine,
verifySession: SSLSession => Try[Unit],
closing: TLSClosing)
extends AtomicModule[BidiShape[SslTlsOutbound, ByteString, ByteString, SslTlsInbound], NotUsed] {

Expand All @@ -46,8 +45,8 @@ import akka.util.ByteString
@InternalApi private[stream] object TlsModule {
def apply(
attributes: Attributes,
createSSLEngine: ActorSystem => SSLEngine, // ActorSystem is only needed to support the AkkaSSLConfig legacy, see #21753
verifySession: (ActorSystem, SSLSession) => Try[Unit], // ActorSystem is only needed to support the AkkaSSLConfig legacy, see #21753
createSSLEngine: () => SSLEngine,
verifySession: (SSLSession) => Try[Unit],
closing: TLSClosing): TlsModule = {
val name = attributes.nameOrDefault(s"StreamTls()")
val cipherIn = Inlet[ByteString](s"$name.cipherIn")
Expand Down
3 changes: 1 addition & 2 deletions akka-stream/src/main/scala/akka/stream/scaladsl/TLS.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ object TLS {
createSSLEngine: () => SSLEngine, // we don't offer the internal `ActorSystem => SSLEngine` API here, see #21753
verifySession: SSLSession => Try[Unit], // we don't offer the internal API that provides `ActorSystem` here, see #21753
closing: TLSClosing): scaladsl.BidiFlow[SslTlsOutbound, ByteString, ByteString, SslTlsInbound, NotUsed] =
scaladsl.BidiFlow.fromGraph(
TlsModule(Attributes.none, _ => createSSLEngine(), (_, session) => verifySession(session), closing))
scaladsl.BidiFlow.fromGraph(TlsModule(Attributes.none, createSSLEngine, verifySession, closing))

/**
* Create a StreamTls [[akka.stream.scaladsl.BidiFlow]].
Expand Down

0 comments on commit 997068c

Please sign in to comment.