1

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.

Adrien
  • 1,080
  • 4
  • 14
  • 1
    can you try switching to `karate-jersey` instead of apache. as far as I know the `NoopHostnameVerifier` is supposed to do it - but only for SSL: https://github.com/intuit/karate/blob/master/karate-apache/src/main/java/com/intuit/karate/http/apache/ApacheHttpClient.java#L153 – Peter Thomas Mar 26 '19 at 12:57
  • I didn't manage to make karate-jersey work. We found a different solution though, which I detailed in the answer below, could you take a look please? Thank you. – Adrien Mar 26 '19 at 14:22

1 Answers1

1

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?

Adrien
  • 1,080
  • 4
  • 14
  • 1
    `LenientSslConnectionSocketFactory` is code in Karate - ideally this should be fixed to make your scenario work - do you think you can debug this and figure ? refer https://github.com/intuit/karate/issues/385 – Peter Thomas Mar 26 '19 at 14:52
  • I found this issue after I posted this solution, as I was trying to figure what would be the best way to fix it. You can reopen it and assign it to me. – Adrien Mar 26 '19 at 15:17
  • 1
    Adrien - can you comment on that ticket once, else I can't assign it (some GitHub permissions thing) – Peter Thomas Mar 26 '19 at 15:23
  • someone reported that `-Djsse.enableSNIExtension=false` works in a comment here: https://stackoverflow.com/q/69123671/143475 – Peter Thomas Sep 10 '21 at 03:02