SNI:SSLHandshakeException unrecognized_name

SNI : SSLHandshakeException unrecognized_name

我在尝试联系某些网站时遇到以下错误:

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

我找到了以下答案:

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

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

但是我还是遇到了和以前一样的问题。我没有找到 public 需要严格的服务器名称指示才能重现我的问题的网站。

我们通过更改 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 连接的参数是否可行?