2

I'm implementing the client side of a protocol (over TCP) which is talking to a server using akka.io.TCP. Depending on how this server is configured, it may or may not support SSL.

To determine whether it supports SSL, first a plain text message is sent to the server (something along the lines of "SslSupported"). The server will then respond with a single character message 'Y'/'N'. In case of a yes, a SSL handshake should be initiated and the remainder of the session should be encrypted. So far, I’ve implemented the protocol for when the server replies with a 'N'.

Currently, I’ve got something along the lines of (note that this is far from the complete code):

IO(Tcp) ! Bind(self, new InetSocketAddress(host, port))

def receive = { 
  case Connected(remote, local) =>
    sender() ! Write(stringToByteString("SslSupported"))
  case Received(data) =>
    data.headOption.map(_.toChar) match {
      case 'N' => // Continue with plain text protocol
      case 'Y' => ??? // Should start with SSL handshake here
    }
}

How would I initiate the SSL handshake and subsequently make sure that all following messages are encrypted?

irundaia
  • 1,720
  • 17
  • 25

0 Answers0