-1

I am encountering an SSLHandshakeException while trying to build and install a React Native app using Gradle on my Windows machine. The error occurs when Gradle attempts to resolve dependencies. Here are the details of the error:

What went wrong:
A problem occurred configuring root project 'app_name'.
> Could not determine the dependencies of task ':gradle-plugin:compileKotlin'.
   > javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 12s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception.  
What went wrong: A problem occurred configuring root project 'app_name'. > Could not determine the dependencies of task ':gradle-plugin:compileKotlin'. > javax.net.ssl.
SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more
help at https://help.gradle.org. 

BUILD FAILED in 12s.

I verified that my internet connection is stable, Executed the build with the --info flag to obtain detailed logs and ran gradlew cleanBuildCache to clear the Gradle cache but nothing seems to work.

1 Answer 1

0

This is often due to SSL inspection enabled on your corporate proxy.

  • Download the certificate of the repository hosting your dependencies e.g Google's Maven repository.

  • Import the downloaded certificate into the JDK truststore using the keytool command. The default truststore is named cacerts and is located in the lib/security folder of your JDK installation directory. Run the following command in your command prompt.

    keytool -import -trustcacerts -keystore <JDK_PATH>\lib\security\cacerts -storepass changeit -noprompt -alias <ALIAS> -file <CERTIFICATE_PATH>
    
  • You can disable SSL verification in Gradle by adding the following lines to your gradle.properties file.

    systemProp.jsse.enableSNIExtension=false 
    systemProp.ssl.SoSecurityOptions=options & CompatibilityLevel=CompatibilityLevel_TLSv1_2
    systemProp.systemProp.javax.net.ssl.trustStore=NUL
    systemProp.systemProp.javax.net.ssl.trustStorePassword=changeit
    
  • Upgrade your JDK.

Not the answer you're looking for? Browse other questions tagged or ask your own question.