Peer not authenticated while importing Gradle project in eclipse

74,246

Solution 1

NOTE: Please ensure the server is trustworthy before you follow these steps.

If you get any other error like this:

 Could not GET 'https://some_server.com/some/path/some.pom'.
     > peer not authenticated

Then you need to import a certificate :

keytool -import -alias <the short name of the server> -file <cert_file_name_you_exported.cer> -keystore cacerts -storepass changeit

It will prompt you to import the certificate, type yes and press enter.

Then restart your eclipse and try building the project.

Solution 2

ANSWER#2:Providing the correct fix after two Negative markings

Make this changes to the top-level build.gradle file.

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        //jcenter()
        jcenter {
            url "http://jcenter.bintray.com/"  <=THIS IS THE LINE THAT MAKES THE DIFFERENCE
        }
    }
}
allprojects {
    repositories {
        //jcenter()
        jcenter {
            url "http://jcenter.bintray.com/" <=THIS IS THE LINE THAT MAKES THE DIFFERENCE
        }
    }
}

ANSWER#1 (Although this is not accepted would like to keep this)

If you see "peer not authenticated errors , it does not necessarily mean that the application does not hold a valid certificate. It also could mean that connections are being reset by the firewall, load balancer, or web servers. Try (re)starting the application with the Administator privilege.

On Windows:

  • Ensure you have administrator privileges.
  • Right Click application icon -> Select "Run as Administrator"

On Linux:

  • Ensure you have root access.
  • type sudo "app execution script name"

Solution 3

Change your repositories to the following in the build.gradle

repositories {
    maven  {
        url "http://repo1.maven.org/maven2"
    }
}

Solution 4

After importing the certificate as suggested in the above answer, edit your gradle.properties file and insert the following lines (having in mind your proxy settings):

HTTPS:

systemProp.https.proxyHost=www.somehost.org
systemProp.https.proxyPort=8080

HTTP:

systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080

Solution 5

Upgrading from java7 to java8 did the trick for me.

Share:
74,246
MrTambourineMan
Author by

MrTambourineMan

All I have in my life is my imagination

Updated on July 17, 2022

Comments

  • MrTambourineMan
    MrTambourineMan 5 months

    While I am importing gradle project in eclipse, it is giving me this error.

    FAILURE: Build failed with an exception.
    * What went wrong:
    A problem occurred configuring root project 'test'.
    > Could not resolve all dependencies for configuration ':classpath'.
       > Could not resolve de.richsource.gradle.plugins:gwt-gradle-plugin:0.3.
         Required by:
             :test:unspecified
          > Could not GET 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/de/richsource/gradle/plugins/gwt-gradle-plugin/0.3/gwt-gradle-plugin-0.3.pom'.
             > peer not authenticated
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    

    I am using internet via proxy connection. If that is the issue, where to specify the proxy settings inside eclipse. In General-->Network connections, proxy settings are already there

    Please help.

  • MrTambourineMan
    MrTambourineMan over 8 years
    Done that. Its still giving the same error. Imported the certificates :(
  • MrTambourineMan
    MrTambourineMan over 8 years
    yes. build path is ok. There were two certificates to import right?
  • dev2d
    dev2d over 8 years
    see, if your buildpath is having referance to JRE you have to import cert to JRE/lib/security/cacerts
  • dev2d
    dev2d over 8 years
    also i think only one cert file you exported needed to be imported in cacerts
  • MrTambourineMan
    MrTambourineMan over 8 years
    yes added it to cacerts. Build path is having reference to JRE. Still same issue
  • dev2d
    dev2d over 8 years
    can you please check if this can help u tools.android.com/tech-docs/new-build-system/…
  • dev2d
    dev2d over 8 years
    see in all what you need to identify is, what keystore is your eclipse referring at the time of import! if it is gradle specific keystore, you need to import the cert in that keystore. because this is just a communication error between your system and GIT server.
  • userv
    userv about 8 years
    Same problem but this is not working for me. check this link where logs and more details regarding the problem is mentioned : groups.google.com/forum/#!topic/adt-dev/C3qWxrS1xrY
  • MFIhsan
    MFIhsan over 7 years
    Thank you so much. It was so complex to figure out this thing especially when gradle was giving weird error.
  • Alexander Prokofyev
    Alexander Prokofyev about 7 years
    Thank you! Thought I should change "changeit" password to something more secure. :)
  • Nabdreas
    Nabdreas about 7 years
    @VD' Hats off mate, fixed my problem! Thanks a lot!
  • dev2d
    dev2d almost 7 years
    it can be anything, if server host is represented as www.google.com, you can provide alias as google, it does not matter as soon as certificate is valid but if you want to list all imported/trusted certs, you can quickly understand that the cert entry with alias "google" represents google.com's cert
  • Cozzbie
    Cozzbie almost 7 years
    Ok thanks. Tried the said solution and build still fails in my case. Using Ionic and trying to build from the CLI.
  • aliteralmind
    aliteralmind almost 7 years
    On OSX. Had to sudo keytool ....
  • RaGe
    RaGe almost 7 years
    The fact that they're getting 'Peer not authenticated' error means that they are already able to reach the repo server, either directly, or they already configured the proxy settings.
  • RaGe
    RaGe almost 7 years
    How does running as admin/sudo on a machine give you elevated privileges on a remote web-server or load balancer?
  • Devendra Vaja
    Devendra Vaja almost 7 years
    It does not give privileges on the remote server. You should read the HTTPS authentication process where the certificate comes into the picture. The access to certification storage location may be accessible only using admin rights and thus the remote server could not validate the client. I hope it is clear now.
  • abudaan
    abudaan over 6 years
    I had the same issue. After importing the certificate from jcenter.bintray.com all .pom files could be downloaded. However I got the "peer not authenticated" error again as soon as the script started downloading the .jar files. But that was fixed after I had edited the build.gradle file as described above.
  • Donal Rafferty
    Donal Rafferty over 6 years
    This worked for me, I was getting the peer not auth error and noticed I had the http proxy set but not the https one set, setting the https proxy to be the same as the http one resolved the issue.
  • subjectivist
    subjectivist over 6 years
    This answer got me going! Thanks. But I would like to know, instead of editing the build.gradle for each of my projects, where does the default gradle information reside for gradle() ? Thanks
  • subjectivist
    subjectivist over 6 years
    See stackoverflow.com/questions/37284472/… . Hopefully it gets an answer.
  • Scott Jungwirth
    Scott Jungwirth over 6 years
    Going through the steps I realized I had CharlesProxy on, disabling it fixed the issue.
  • subjectivist
    subjectivist over 6 years
    I placed vbscript at the following SO question to fix this issue in new projects: stackoverflow.com/questions/37284472/…
  • MarcFasel
    MarcFasel over 2 years
    Seems like http is not allowed for maven repo anymore. I get a 501 error: HTTPS Required
  • MarcFasel
    MarcFasel over 2 years
    Seems like http is not allowed in JCenter anymore. I get a 403: Forbidden error