Plays WS handshake_failure exception even with ws.acceptAnyCertificate = true

I am using Play WS to upload a file, but I am getting an exception handshake_failure

, even with ws.acceptAnyCertificate = true

.

// libraryDependencies += "com.typesafe.play" %% "play-ws" % "2.5.15"
import akka.actor._
import akka.stream._
import akka.util.ByteString
import play.api.libs.ws.WSResponse
import play.api.libs.ws.ahc._

import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}

implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
val ws = AhcWSClient()

println(ws.config.isAcceptAnyCertificate) // false

def getBody(future: Future[WSResponse]): ByteString = {
  val response: WSResponse = Await.result(future, Duration.Inf)
  if (response.status != 200)
    throw new Exception(response.statusText)
  response.bodyAsBytes
}

def download(url: String): ByteString =
  HttpUtils.getBody(ws.url(url).withFollowRedirects(true).get())

download("https://www.tivo.com/legal/patents")
// Exception in thread "main" java.net.ConnectException: Received fatal alert: handshake_failure

      

In a game application, I can create a conf/application.conf

text file ws.acceptAnyCertificate=true

. But I am using play-ws as lib, not as application. So I am doing the following:

val loose = SSLLooseConfig(acceptAnyCertificate = true, allowWeakCiphers = true, allowWeakProtocols = true, allowUnsafeRenegotiation = Option(true))
val sslConfig = SSLConfig(loose = loose)
val wsClientConfig = WSClientConfig(ssl = sslConfig)
private val config = AhcWSClientConfig(wsClientConfig)
val ws = AhcWSClient(config)
println(ws.config.isAcceptAnyCertificate) // true

      

However, I still get the same exception:

download("https://www.tivo.com/legal/patents")
// Exception in thread "main" java.net.ConnectException: Received fatal alert: handshake_failure

      

It works with uploads (" https://www.epfl.ch/ ") but not uploads (" https://www.tivo.com/legal/patents ")

How to solve this?

+3


source to share





All Articles