pksimba
pksimba

Reputation: 193

Set https support for Akka server with .ca-bundle, .crt and .key files

I have a simple Akka http server, but I have to set https support. I have three files for the certificate : .crt, .key and .ca-bundle In Akka doc, there is only PKCS12 example. How can i do with the files that I have ?

def initializeWebServer(interface: String,
                          port: Int) = {

        val route : Route =
          pathPrefix("secured") {
            authenticateOAuth2(realm = "secure site", checkAuthentication){ token =>
            concat(
              get{
                path("hello"){
                  complete("hello world")
                }
              }
            )
          }
        }

    val bindingFuture = Http().bindAndHandle(route, interface, port.toInt)
    CoordinatedShutdown(system).addJvmShutdownHook({
      bindingFuture
        .flatMap(_.unbind())
    })
  }

  def myUserPassAuthenticator(credentials: Credentials): Option[String] =
    credentials match {
      case [email protected](id) if p.verify("secret") => Some(id)
      case _ => None
    }

  def checkAuthentication(credentials: Credentials): Option[String] = credentials match {
    case p @ Credentials.Provided(token) if p.verify("secret") => Some(token)
    case _ => None
  }

Upvotes: 1

Views: 206

Answers (1)

pksimba
pksimba

Reputation: 193

Thank's to @Leo C 's comment,

Upvotes: 2

Related Questions