gpt4 book ai didi

scala - 使用 .ca-bundle、.crt 和 .key 文件为 Akka 服务器设置 https 支持

转载 作者:太空宇宙 更新时间:2023-11-03 13:19:45 24 4
gpt4 key购买 nike

我有一个简单的 Akka http 服务器,但我必须设置 https 支持。我有三个证书文件:.crt、.key 和 .ca-bundle在 Akka 文档中,只有 PKCS12 示例。我该如何处理我拥有的文件?

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 p@Credentials.Provided(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
}

最佳答案

感谢@Leo C 的评论,

关于scala - 使用 .ca-bundle、.crt 和 .key 文件为 Akka 服务器设置 https 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59533287/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com