akka http SSLConfig issues with Hostname verification and cert validation
<p>I have some issues with Akka http configuration on the client side. I am trying to connect to a server which doesn't provide:
- a public signed certificate
- a certificate corresponding to the hostname
I don't have the hand on this nginx so I cannot change the server side configuration. I can only change the client side.</p>

<p>After lots of investigation on configuring SSL, I have found that I need to configure SSL options in <strong>application.conf</strong> at two different levels :</p>

<pre><code>akka.ssl-config.ssl.loose.acceptAnyCertificate=true
akka.ssl-config.loose.disableHostnameVerification = true
</code></pre>

<p>and </p>

<pre><code>ssl-config.loose.acceptAnyCertificate=true
ssl-config.loose.disableHostnameVerification = true
</code></pre>

<p>I have checked the configuration is fine with </p>

<pre><code>log-config-on-start = "on" 
</code></pre>

<p>The problem is that I still get error at  the akka debug level (not very clear)</p>

<pre><code>[ingestionApiClient-akka.actor.default-dispatcher-13] [akka://ingestionApiClient/user/StreamSupervisor-0/flow-216-1-unknown-operation] closing output
</code></pre>

<p>Looking at wireshark I have found that's a problem of certificate validation</p>

<pre><code>TLSv1 Record Layer: Alert (Level: Fatal, Description: Certificate Unknown)
</code></pre>

<p>I suppose the JVM configuration is overiding all I have done so I also tried to follow this method to modify JVM SSL config :
<a href="https://stackoverflow.com/questions/6031258/java-ssl-how-to-disable-hostname-verification">Java SSL: how to disable hostname verification</a></p>

<p>No problem with configuring the SSLContext and passing it to akka http because I can set the default HttpsContext with </p>

<pre><code>val sc = SSLContext.getInstance("TLS")
*...configuration...*
val customContext =HttpsContext(sc, sslParameters = Some(params))
Http().setDefaultClientHttpsContext(customHttpsContext)
</code></pre>

<p>But I cannot find anyway to configure the default hostname verifier. The Http class doesn't have any method like <code>Http().setDefaultHostnameVerifier</code></p>

<p>This how I connect to the server</p>

<pre><code>val dataIngestFlow = Http().outgoingConnectionTls(config.httpEndpointHost,config.httpEndpointPort)
</code></pre>

<p>How can I achieve this ? Thanks a lot for your help</p>