'How to remove deprecated AkkaSSLConfig using createSSLEgine

I'm trying to remove AkkaSSLConfig from code usage. Below is my code.

    import com.typesafe.sslconfig.akka.AkkaSSLConfig
    import akka.http.scaladsl.HttpsConnectionContext

    val sslConfig = AkkaSSLConfig().mapSettings (s => s.withLoose(s.loose.withDisableSNI(true).withAcceptAnyCertificate(true).withDisableHostnameVerification(true)))

    val nonValidatingContext: SSLContext = {
        class IgnoreX509TrustManager extends X509TrustManager {
          def checkClientTrusted(chain: Array[X509Certificate], authType: String): Unit = {}

          def checkServerTrusted(chain: Array[X509Certificate], authType: String): Unit = {}

          def getAcceptedIssuers = null
        }

        val context = SSLContext.getInstance("TLSv1.2")
        context.init(null, Array(new IgnoreX509TrustManager), null)
        context
    }

    new HttpsConnectionContext(nonValidatingContext, Some(sslConfig))

I don't know how to set these configuration val sslConfig = AkkaSSLConfig().mapSettings (s => s.withLoose(s.loose.withDisableSNI(true).withAcceptAnyCertificate(true).withDisableHostnameVerification(true))) in SSLContext without using AkkaSSLConfig.

Any idea how to set these params?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source