1

I'm working on a new laptop on my office network behind a corporate proxy and I keep getting "PKIX path building failed ... unable to find valid certification path to requested target" when my project builds and tries to download the Gradle Plugin pom.

The prevailing wisdom at my company with regard to the proxy is to:

  1. Set the Preferences > Tools > Server Certificates item "Accept non-trusted certificates automatically" to "checked"

  2. Edit Help > Edit Custom VM Options to add "-Djavax.net.ssl.trustStoreType=KeychainStore" (the pertinent certificates appear to be in Keychain)

Despite setting those, I still get:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'AuditTrail'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve org.grails:grails-gradle-plugin:4.0.6.
     Required by:
         project :
      > Could not resolve org.grails:grails-gradle-plugin:4.0.6.
         > Could not get resource 'https://repo.grails.org/grails/core/org/grails/grails-gradle-plugin/4.0.6/grails-gradle-plugin-4.0.6.pom'.
            > Could not GET 'https://repo.grails.org/grails/core/org/grails/grails-gradle-plugin/4.0.6/grails-gradle-plugin-4.0.6.pom'.
               > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

...

* Get more help at https://help.gradle.org

BUILD FAILED in 486ms```
 
Jim Gough
  • 148
  • 3
  • 12

1 Answers1

2

To run a Gradle build and import a Gradle project, IDE uses the JDK which is different from the JDK which is used by IDE to run itself. So you need to add your company's certificate into the JDK which is specified in Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Gradle JVM.

See Import the Certificate as a Trusted Certificate in Oracle's documentation.

If you want to specify the JVM options for Gradle, use gradle.properties file in the the project directory where your building script is located.

systemProp.javax.net.ssl.trustStoreType=KeychainStore

See also https://stackoverflow.com/a/43486698/2000323

Andrey
  • 15,144
  • 25
  • 91
  • 187