karate

How to skip SSL certificate verification with karate?


I'm trying to turn off SSL certificate verification through karate. For now I'm getting error:

       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: 

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


Solution

  • Please do this:

    * configure ssl = true
    

    Read the docs for more: https://github.com/intuit/karate#configure

    EDIT: for those landing here in the future (and on Karate version < 1.0), I recently realized that if the above fails, it is most likely that you have added Karate to a Java Maven (or Gradle) project that has a different version of the Apache HTTP Client libraries in scope. And what happens is that the JAR conflict causes some SSL related classes to fail to load.

    There are 2 solutions:

    1. use karate-jersey instead of karate-apache
    2. force the version of the Apache dependencies like this:
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>${apache.version}</version>
         </dependency>
    

    The value of apache.version depends on what your project needs and what Karate depends on, and in most cases, using the latest possible version would work.

    EDIT 2023: Note that from Karate 1.2.0 onwards using the Karate fat-jar can solve similar issues. Refer to the documentation: https://github.com/karatelabs/karate#karate-core-fat-jar