0

as provided in docs and here, I was trying to change HostnameVerifierClass using following code:

val sslConfig = AkkaSSLConfig().mapSettings { s =>
  s.withHostnameVerifierClass(java.lang.Class[NoopHostnameVerifier])
  s
}
val badCtx = Http().createClientHttpsContext(sslConfig)
Http().superPool[RequestTracker](badCtx)(httpMat)

But I am getting following error with this:

Error:(83, 31) object java.lang.Class is not a value s.withHostnameVerifierClass(JJClass[NoopHostnameVerifier])

Getting help from this answer, I changed it to:

val sslConfig = AkkaSSLConfig().mapSettings { s =>
  s.withHostnameVerifierClass(classOf[NoopHostnameVerifier])
  s
}

But this also does not compile saying:

Error:(83, 38) type mismatch;

found : Classorg.apache.http.conn.ssl.NoopHostnameVerifier

required: Class[javax.net.ssl.HostnameVerifier]

Note: org.apache.http.conn.ssl.NoopHostnameVerifier <: javax.net.ssl.HostnameVerifier, but Java-defined class Class is invariant in type T.

You may wish to investigate a wildcard type such as _ <: javax.net.ssl.HostnameVerifier. (SLS 3.2.10)

s.withHostnameVerifierClass(classOf[NoopHostnameVerifier])

How do I get around this, NoopHostnameVerifier implements interface HostnameVerifier, but still this error coming.

Saurabh
  • 71,488
  • 40
  • 181
  • 244
  • Have you seen [this issue](https://github.com/lightbend/ssl-config/issues/46), it seems to be about the same thing. Are you using the latest version of `ssl-config`? – Kraylog Nov 18 '17 at 09:35

1 Answers1

0

Yes, as suggested in comments, it was due to issue in ssl-config, by upgrading version to 0.2.2, following code started working:

val sslConfig = AkkaSSLConfig().mapSettings { s =>
  s.withHostnameVerifierClass(classOf[VerifiesAllHostNames]) 
  s
}
Saurabh
  • 71,488
  • 40
  • 181
  • 244