我正在尝试通过自定义 ssl 配置在我的 Play 应用程序中使用 WSClient,但它不起作用。
我的控制器如下所示:
@Singleton
class HomeController @Inject()(cc: ControllerComponents, ws: WSClient, configuration: Configuration) extends AbstractController(cc) {
implicit val timeout: Timeout = 5 seconds
def index() = Action.async {
val url = "https://our-microservice-endpoint.com"
ws.url(url).get().map {
response =>
Ok((response.xml \\ "payload").head.text)
}
}
}
我已将以下 ssl-config 对象添加到application.conf
:
ssl-config {
keyManager = {
stores = [
{ type = "JKS", path = "client.jks", password = "changeit1" }
]
}
trustManager = {
stores = [
{ type = "JKS", path = "exampletrust.jks" }
]
}
}
(显然我的本地设置已经到位)。我知道我传递给密钥存储和信任存储的值是有效的,因为它们是我在其他应用程序中使用的值。
但是,如果我调试应用程序并查看已注入的 wsclient,它似乎没有 ssl 设置。当我运行控制器时,我得到一个 ssl handshake_failure
。
我错过了什么还是这一切都错了?我正在使用最新的播放框架版本 2.6。
谢谢