4

I am trying to use the WSClient in my Play app with a custom ssl config, but it's not working.

My controller looks like this:

@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)
    }
  }
}

And I have added the following ssl-config object to application.conf:

ssl-config {
  keyManager = {
    stores = [
      { type = "JKS", path = "client.jks", password = "changeit1" }
    ]
  }
  trustManager = {
    stores = [
      { type = "JKS", path = "exampletrust.jks" }
    ]
  }
}

(Obviously with my local settings in place). I know the values that I am passing to the key stores and the trust stores work because they are the ones I use in other applications.

However I if I debug the app and look at the wsclient that has been injected it seems to have no ssl settings. And when I run the controller I get an ssl handshake_failure.

Am I missing something or is this all wrong? I am using the latest play framework release 2.6.

Thanks

mattl
  • 2,082
  • 3
  • 17
  • 24

1 Answers1

0

There is a note here that "ssl-config" isn't the root key: https://www.playframework.com/documentation/2.8.x/WsSSL#Table-of-Contents

NOTE: The links below are relative to Typesafe SSLConfig, which uses the ssl-config as a prefix for ssl properties. Play uses the play.ws.ssl prefix, so that, for instance the ssl-config.loose.acceptAnyCertificate becomes play.ws.ssl.loose.acceptAnyCertificate for your play WSClient configuration.

Perhaps try replacing "ssl-config" in application.conf with "play.ws.ssl". I had to dig a bit to find that one; it's a bit confusing.

Jonathan Crosmer
  • 786
  • 5
  • 19