Search code examples
karatesslhandshakeexceptionsni

SNI : SSLHandshakeException unrecognized_name


I have the following error when trying to contact some website :

10:29:32.228 [ForkJoinPool-1-worker-1] ERROR com.intuit.karate - javax.net.ssl.SSLHandshakeException: Received fatal alert: unrecognized_name, http call failed after 35 milliseconds for URL: https://{redacted}
10:29:32.229 [ForkJoinPool-1-worker-1] ERROR com.intuit.karate - http request failed: javax.net.ssl.SSLHandshakeException: Received fatal alert: unrecognized_name

I have found the following answer : https://stackoverflow.com/a/14884941/10791639

I edited karate-apache/src/main/java/com/intuit/karate/http/apache/ApacheHttpClient.java L125, removing the comment from this line :

System.setProperty("jsse.enableSNIExtension", "false");

But I still have the same problem as before. I haven't found a public website that is requiring strict Server Name Indication to reproduce my problem.


Solution

  • We found a solution by changing something in karate-apache/src/main/java/com/intuit/karate/http/apache/ApacheHttpClient.java :

    SSLConnectionSocketFactory socketFactory = new LenientSslConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
    

    becomes

    SSLConnectionSocketFactory socketFactory = new SslConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
    

    @Peter, do you think a parameter to use strict or lenient SSL connection can be a possibility?