cURL Always Returns 401 With NTLM

10,051

This is an old question but if it can eventually help anybody, I figured I'd post an answer.

There's a bug with NTLM and curl on certain recent version of Ubuntu (10.04 and up I believe).

If you're using the curl module of PHP on ubuntu and your libcurl version is affected by this bug, this could explain why your authentication requests are failing.

If you add the verbose flag to your command (-v), you should see something like this in the response part:

  • gss_init_sec_context() failed: : Credentials cache file '/tmp/krb5cc_1000' not found

If you do see this, you're affected by the bug and you'll have to either downgrade your library or find another machine.

I hope this helps :P

Share:
10,051
JamesArmes
Author by

JamesArmes

Updated on July 05, 2022

Comments

  • JamesArmes
    JamesArmes almost 2 years

    I'm working on a library to communicate with Microsoft Exchange using PHP. Everything works fine on my production servers, but I keep getting a 401 Unauthorized on my development machine. I tried using curl from the command line and I get the same results.

    Using the following returns "401" on my machine:

    curl https://mail.example.com/EWS/Exchange.asmx -w %{http_code} --ntlm -u username:password
    

    The same exact call returns "302" on my production machines, which is what I expect.

    My development machine is using curl 7.19.7 and my production machine is using curl 7.18.0.

  • JamesArmes
    JamesArmes over 12 years
    I recently found this bug report as well, I really should have updated here to reflect that. For reference, this is where I originally encountered the issue: github.com/jamesiarmes/php-ews/issues/11.
  • Nunser
    Nunser about 11 years
    I know the link gives indications to an answer, but link-based answers turn obsolete if the link doesn't work. Could you please consider summarize what the link you provided says in your answer?
  • Admin
    Admin about 11 years
    There is a bug inside curl which pervent the authentication. In the bugzilla an patch is available. It will be included in centos/rhel 6.5.
  • Johann
    Johann about 11 years
    This is also confirmed against CentOS 6.4: bugzilla.redhat.com/show_bug.cgi?id=799557 (I know the title of the bug makes it look like it's unrelated, but this is the same bug.)