开发者

cURL Always Returns 401 With NTLM

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.


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).

  • Ubuntu: https://bugs.launchpad.net/ubuntu/+source/curl/+bug/675974
  • CentOS: https://bugzilla.redhat.com/show_bug.cgi?id=799557

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


For all Centos / RHEL 6.X Users please take a look into:

https://bugzilla.redhat.com/show_bug.cgi?id=953864

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜