10

I upgrade the projects Gradle version from 5.4.1 to 6.8.3 and have changed the custom repository to https.

I had a similar issue with maven but after mirroring has been solved. I can build the project without anyproblem with gradle 5.4.1 but when I upgrade the gradle to 6.8.3 then I got the following error:

        The server may not support the client's requested TLS protocol versions: (TLSv1.2). You may need to configure the client to allow other protocols to be used.
     See: https://docs.gradle.org/6.8.3/userguide/build_environment.html#gradle_system_properties
                          > sun.security.validator.ValidatorException: 
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
celcin
  • 304
  • 1
  • 4
  • 14
  • 1
    There is not enough information about the problem. we need comprehensive information about the project. you are using Docker and containers. However, you didn't put any information about that. run-time env is important, 32bit or 64bit system or software is important, JRE, JDK how you containerize is important. and so. please provide as much information as you can. thanks – A Farmanbar Sep 30 '21 at 15:06

3 Answers3

9

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

You get this message when the JRE is missing a certificate. I think you are going to have to install your company's certificate in the docker image's JRE

Your Dockerfile will need to do something like:

FROM adoptopenjdk/openjdk11:jre-11.0.11_9-alpine

// my-company.crt is your company's certificate
COPY my-company.crt my-company.crt

RUN keytool -cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias my-alias -file my-company.crt
lance-java
  • 25,497
  • 4
  • 59
  • 101
  • 1
    curiously with `jdk8` I am having still the same issue. But with JDK 11 it works – celcin Oct 01 '21 at 14:36
  • I'm assuming that's a different docker image, have you installed the certificate in both images? – lance-java Oct 02 '21 at 10:54
  • Yes, I did the same steps. The only difference is the jdk8 image does not run `RUN keytool -cacerts -storepass changeit -noprompt -trustcacerts -importcert -alias begoroot -file my-company.crt` with `-cacerts` flags. I ran without `-cacerts`. – celcin Oct 02 '21 at 21:48
  • 1
    I think with java 8 you'll need to do `-file $JAVA_HOME/lib/security/cacerts` instead of `-cacerts` – lance-java Oct 03 '21 at 01:48
0

The following solution worked for me. I just disabled TLS

In Repositories section of your gradle:

Replace mavenCentral() with

maven { 
    url = "http://repo.maven.apache.org/maven2"
    allowInsecureProtocol = true
} 

and jcenter() with

maven { 
    url = "http://jcenter.bintray.com"
    allowInsecureProtocol = true
} 

and for any other repositories just use the url with HTTP protocol instead of HTTPS and make sure to set allowInsecureProtocol = true

  • And I need to point out that if you are behind a network firewall like me and you're using windows and need to connect to internet through a proxy, make sure to use a software that tunnels your whole traffic through that proxy like Proxifier – mohammad reza sarsarabi Feb 01 '23 at 12:30
  • Does not work here – Azghanvi Apr 24 '23 at 09:30
0

In my case, this error was a result of my internet service provider using a custom CA certificate to intercept and filter my SSL traffic.

Once I connected to the internet with a proper CA certificate chain the build completed without error.

Notes:

  1. This error can be a result of any SSL certificate / CA issue on you internet connection.

  2. Once the build completes all is good until the build needs to download a new gradle version.

AAber
  • 1,562
  • 10
  • 14