Reputation: 193
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
Reputation: 193
Thank's to @Leo C 's comment,
Convert key and crt to p12 :
openssl pkcs12 -export -out server.p12 -inkey server.key -in server.crt
Implementation of the solution with SSL : https://doc.akka.io/docs/akka-http/current/server-side/server-https-support.html
Upvotes: 2