SNI:SSLHandshakeException无法识别的名称

时间:2019-03-26 09:49:07

标签: karate sslhandshakeexception sni

尝试联系某些网站时出现以下错误:

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

我找到了以下答案:https://stackoverflow.com/a/14884941/10791639

我编辑了karate-apache/src/main/java/com/intuit/karate/http/apache/ApacheHttpClient.java L125,从此行中删除了注释:

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

但是我仍然有和以前一样的问题。我没有找到需要严格的服务器名称指示来重现我的问题的公共网站。

1 个答案:

答案 0 :(得分:1)

我们通过更改karate-apache/src/main/java/com/intuit/karate/http/apache/ApacheHttpClient.java中的内容找到了解决方案:

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

成为

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

@Peter,您认为使用严格或宽松的SSL连接的参数是否可能?