SSL TCP socket on Scala with Akka

Using Scala 2.10 and Akka 2.3.4, I put together a simple proxy server that accepts incoming TCP connections and then proxies these messages to a remote server. Everything works with plain text, but I'm stuck in SSL.

In short, this is how I start my insecure server for incoming connections:

val server = system.actorOf(Props(new LegacyTCPServer), name = "my-tcp-server") implicit val bindingTimeout = Timeout(1.second) import system.dispatcher // execution context for the future val boundFuture = IO(Tcp) ? Tcp.Bind(server, endpoint) boundFuture.onSuccess { case Tcp.Bound(address) => println("Fantastic! We have a connection: " + address) } 

I can connect to this server via telnet, but now I want to move no to opensl. I assume that there must be some configuration parameters for this, but I cannot parse them from the documentation: http://doc.akka.io/docs/akka/2.3.4/scala.html

I saw some (non-functional) examples using akka 2.2.x that use TCPPipelineHandler, for example,

https://groups.google.com/forum/#!topic/akka-user/auErrrk9wS0

https://github.com/betehess/ping-pong-bot/blob/master/app/ircbot/IrcClient.scala#L183

but TCPPipelineHandler does not seem to exist in akka 2.3.x, so it looks like a dead end.

I would really like it if someone could provide an example of how to configure a tcp socket on ssl using the current versions of Scala and Akka.

Please let me know if you need more information. Thanks!

+4
source share
1 answer

spray is an HTTP server / client built on top of Akka IO.

In the infrastructure "io.spray" % "spray-io" % "1.3.1" there is a pipeline infrastructure and SslTlsSupport. I use it in a project that I am currently working on. See How it is configured for the HttpServerConnection in a spray for more information.

You will need to reorganize your code in order to use pipelines from the spray, it will become much easier from my code of experience if you divide your code into several stages, each of which is responsible for a small piece.

+1
source

Source: https://habr.com/ru/post/975314/


All Articles