Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Cannot access repositories via basic auth proxy

When I try to run the quick start sample with gradle , I get the below error. I have done the proxy configuration as per the gradle manual.

D:\gradle\gradle-1.2\samples\java\quickstart>gradle build
:compileJava
NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could no
t load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file s
pecified))

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not resolve group:commons-collections, module:commons-collections, versi
on:3.2.
Required by:
:quickstart:1.0
> Could not HEAD 'http://repo1.maven.org/maven2/commons...
ollections/3.2/commons-collections-3.2.pom'. Received status code 407 from serve
r: Proxy Authentication Required

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 4.406 secs
1 person has
this question
+1
Reply
  • Can you double-check that you have correctly configured proxy authentication?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • this is the gradle.properties which I have placed in the project root

    systemProp.http.proxyHost=
    systemProp.http.proxyPort=
    systemProp.http.proxyUser=
    systemProp.http.proxyPassword=
    systemProp.http.nonProxyHosts=localhost
    systemProp.http.auth.ntlm.domain=
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited

  • Well, the values matter too. :-)

    Did you use `[domain]/[username]` for `proxyUser`? In that case, you don't have to set `http.auth.ntlm.domain`.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited

  • I've upgraded Apache HttpClient from 4.2.1 to 4.2.2. You'll be able to give it a try in tomorrow's nightly build. If that doesn't help, you may have to do some research on your own. Maybe you find something in the debug log (`-d`) that leads you to a solution.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • OK Thanks. I will try that out tomorrow.

    I already tried replacing httpclient and httpcore from 4.2.1 to 4.2.2 and renaming the jar file ( as it was suggested in some other forum ) - but i got the same error again.

    I will try again with the new build .

    From the debug , I could find that the the request was getting routed through the proxy ( just to confirm the setting took effect ) - but the credential were not getting applied.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • I tried the nightly build . I get the same error again

    The difference in the new build is that I get the below error continously .

    D:\gradle\gradle-1.2\samples\java\quickstart>gradle build
    :compileJava UP-TO-DATE
    :processResources UP-TO-DATE
    :classes UP-TO-DATE
    :jar UP-TO-DATE
    :assemble UP-TO-DATE
    :compileTestJava
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\WINDOWS\krb5.ini (The system cannot find the file specified))
    • view 7 more comments
    • Did anybody face this problem ? please share if there is any work around
    • Same here (but did not find a work around).

      Started from scratch. - All I wanted to do is to build spring webflow cloned from github [1].

      Added my proxy configuration to the gradle.properties file:

      systemProp.http.proxyHost=
      systemProp.http.proxyPort=
      systemProp.http.proxyUser=
      systemProp.http.proxyPassword=

      And run "gradlew build".

      The first part went fine (proxy-configuration works!)
      Downloading http://services.gradle.org/distributi...
      Unzippinig....

      But then:
      "NEGOTIATE authentication error: Invalid name provided (Mechanism level: Could not load configuration file C:\Windows\krb5.ini ..."

      Env: Win7 - jdk 1.6.0_37

      [1] https://github.com/SpringSource/sprin...
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited

  • After spending some time , I found only two solutions to the above problem.

    1.Comment out setting NTLM Credentials in org.gradle.api.internal.externalresource.transport.http.HttpClientConfigurer -> useCredentials() .
    I am not sure whether this is correct since BASIC authentication works even without this change as per the previous comments for this issue.

    2. Set BASIC as the preferred scheme.I tried setting "systemProp.http.auth.preference=Basic" in gradle .properties , but it is not considerd by httpclient.
    The other way is to programatically set it in the HttpClient as below

    List authpref = new ArrayList();
    authpref.add(AuthPolicy.BASIC);
    client.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref);

    I could not find a way to configure or pass the above as system properties to gradle . The only option is modify gradle source code which will be a problem
    if i want to move to later versions.

    So , giving up :( in case if any body has any ideas ,please share
    • view 1 more comment
    • Thanks for the response .
      find the stack trace below

      https://gist.github.com/4175447
    • If you can provide a mechanism to specify the preferred authentication scheme via gradle.properties ( some thing like systemProp.http.auth.preference=basic or some other system property ) and if this value is set in httpclient , then it will be very useful.

      List authpref = new ArrayList();
      authpref.add(AuthPolicy.BASIC);
      client.getParams().setParameter(AuthPNames.PROXYAUTHPREF, authpref);


      It will also help avoiding checking for unnecessary schemes ( NTLM ,NEGOTIATE ) in my case and try for only BASIC authentication for every fetch
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited

  • Daz DeBoer (Gradleware Engineer) December 05, 2012 19:19
    While providing an explicit override is an option (I've now raised GRADLE-2589 for this), we _really_ want gradle to work out of the box without requiring extra configuration like this. So I'd rather get to the bottom of what's causing your issue. If one scheme fails, we should move onto the next.

    Inspecting your debug logs, it looks like this happens:
    * Your proxy is responds with 407 (proxy auth required), declaring that it supports NEGOTIATE, NTLM and BASIC authentication
    * Negotiate is not available on the client side, so is ignored (with a warning)
    * NTLM authentication is attempted using the username/password supplied.
    * NTML authentication fails and responds with another 407, but the proxy server no longer lists BASIC in the set of available authentication schemes (only NTLM is listed).
    * For some reason, HttpClient does not attempt the request with BASIC auth. Possibly the subsequent 407 request is parsed and since BASIC is no longer listed, it is not attempted.

    I suspect a bug in Apache HttpClient, but without access to your environment it's very hard to debug this issue. You could greatly help us resolve this problem, by experimenting with your direct HttpClient sample using NTMLCredentials. When NTML authentication fails, an attempt should be made to authenticate with Basic auth, I think. If you can prove this isn't happening in a simple sample using HttpClient, we could file a bug report.

    It could be that you're hitting a bug similar to https://issues.apache.org/jira/browse..., but with proxy authentication instead of regular http authentication. But I'm certainly no expert in proxy authentication.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned

  • Thanks Daz for the response.

    Find the log below for direct http client without NT Credentials

    https://gist.github.com/d08654e3d7c90...

    Find below the log for direct http client after setting org.apache.http.auth.NTCredentials in http Client

    https://gist.github.com/f5b902d614d01...
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited

  • Daz DeBoer (Gradleware Engineer) December 09, 2012 21:18
    Hi again, and thanks for the data. It looks like your proxy does indeed support NTLM authentication, and you're successfully authenticating using that method (in your second example). The 2 questions I have now are:

    1- Why is Gradle rejecting your NTLM credentials? Can you please verify the values that are being sent by Gradle against the values you're using in your test app? You can see the values Gradle is using by looking for a line like this in your debug logs:

    08:32:13.809 [DEBUG] [org.gradle.api.internal.externalresource.transport.http.HttpClientConfigurer] Using Credentials [username: MY_USER_ID] and NTLM Credentials [user: MY_USER_ID, domain: MY_DOMAIN, workstation: MY_WORK_STATION] for authenticating against 'MYPROXY:8080'


    2- What happens in your direct HTTPClient test if you supply the incorrect NTLM credentials? You could try setting the invalid value for Domain or Workstation. The goal would be to see if HTTPClient will attempt Basic Auth if NTLM fails when NTML Credentials are supplied.

    If you don't mind working through this with me, I'd love to get to the bottom of it. Proxy authentication is the source of a lot of problems for new users and experienced users alike.
    • view 12 more comments
    • Daz DeBoer (Gradleware Engineer) December 18, 2012 06:21
      Yep, agreed about the documentation. Feel free to submit a patch to the user guide :).

      Apparently this has been recognised as a bug in HttpClient and will be fixed in 4.2.3. Thanks for reporting and helping us get to the bottom of it.
    • Sure. I will try to submit the patch. Thanks.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited

  • Daz DeBoer (Gradleware Engineer) December 10, 2012 19:21
    I've raised [HTTPCLIENT-1272](https://issues.apache.org/jira/browse...) for the issue where HttpClient does not attempt BASIC auth after NTLM fails against a proxy.

    Can you please add any relavent information to that ticket?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • Hi

    I've read through this thread and the HTTPCLIENT-1272 Jira.

    The Jira is not being fixed and there wasnt a clear resolution from a Gradle perspective. This thread has also reached a dead end so could someone point out the solution.

    Maven works fine, so its quite frustrating that we cant use Gradle, especially when certain spring projects (e.g. spring-data-rest) are Gradle only.

    Thanks
    SL
    • view 2 more comments
    • Ive also tried:

      systemProp.http.proxyHost=myHost
      systemProp.http.proxyPort=myPort
      systemProp.http.auth.ntlm.domain=mydomain
      systemProp.http.proxyUser=myusername
      systemProp.http.proxyPassword=mypwd
      systemProp.http.keepAlive=true

      which yielded the same result
    • Daz DeBoer (Gradleware Engineer) March 07, 2013 19:12
      That looks a lot like the warning that is commonly emitted by HttpClient, not an actual error. The actual error will be in the form of a stack trace. Debug logs are also useful.

      If you want to follow up on this:
      1) Start a new forum topic
      2) Post your stack trace inside <code/> tags
      3) Post your debug logs via GitHub gist.

      I won't be replying to new questions in this forum topic.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited indifferent, undecided, unconcerned