我正在尝试通过空手道关闭 SSL 证书验证。现在我收到错误:
13:27:14.668 [main] ERROR com.intuit.karate - javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target, http call failed after 133 milliseconds for URL: https://VRNV02AS04294.int.carlsonwagonlit.com:8443/admin/property/filters/APFilter/true
13:27:14.668 [main] ERROR com.intuit.karate - http request failed:
Run Code Online (Sandbox Code Playgroud)
javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径
请这样做:
* configure ssl = true
Run Code Online (Sandbox Code Playgroud)
阅读文档了解更多信息: https: //github.com/intuit/karate#configure
编辑:对于那些将来登陆这里的人(以及空手道版本<1.0),我最近意识到,如果上述失败,很可能您已将空手道添加到具有不同版本的Java Maven(或Gradle)项目中范围内的 Apache HTTP 客户端库。发生的情况是 JAR 冲突导致一些 SSL 相关类无法加载。
有2种解决方案:
karate-jersey而不是karate-apache <dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${apache.version}</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
的值apache.version取决于您的项目需求以及空手道所依赖的内容,并且在大多数情况下,使用最新的可能版本是可行的。
编辑 2023:请注意,从空手道 1.2.0 开始,使用空手道 fat-jar 可以解决类似的问题。参考文档: https: //github.com/karatelabs/karate#karate-core-fat-jar