In our PHP application, we need the PHP curl-extension built in a way, that it supports the following features:
- WinSSL (Access to the Windows certificate store)
- NTLM, Basic and Digest authentication
- HTTP/2 support
- SSH2 support
- IPv6 support
I've tried to build curl in a way to achieve this:
- Link it against WinSSL
- Link it against nghttp2
- Link it against libssh2
- Enable IPv6
I did so with the command line:
nmake /f Makefile.vc mode=dll VC=15 ENABLE_WINSSL=yes DEBUG=no MACHINE=x64 ENABLE_SSPI=no WITH_NGHTTP2=dll WITH_ZLIB=static WITH_SSH2=static WITH_DEVEL=C:\curl\deps-x64
In curls winbuild/
subfolder. Then I compiled the PHP curl extension against the result.
With the result, I have the following incorrect behavior when doing an HTTP request against a web service which offers Basic, Digest, NTLM and Negotiate authentication (an Exchange webservice):
If
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
is used, everything works fine.If
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
is used, everything works fine, too.If
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM | CURLAUTH_BASIC);
is used, authentication fails.
The failing request contains an NTLM token which is way too short (seems to be cut off at some point). Some googling indicated that this may be due to curl being compiled to use SSPI. However, I cannot disable SSPI, because WinSSL requires it.
Does anyone know a solution to this? How to get a php-curl extension that fulfills all the above requirements?
CURLAUTH_NTLM | CURLAUTH_BASIC
? – Domino401 Unauthorized
response with WWW-Authenticate headers, chooses an authentication mechanism depending on the headers from that response and from the configured allowed authentication methods, and then sends the request again, authenticated using the chosen method (NTLM in this case) – TrahurnCURLAUTH_ANY
? Would be interesting to see the response headers from the server as well. – Altarpiececurl_setopt($ch, CURLOPT_USERPWD, "USER:PWD");
? Would be interesting, if the first auth-negotiation request is then no longer401
, but authed. Also, if there is forwarding/follow-location involved, thencurl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, true);
comes into play. All in all, hard to say, without looking at the code or request logs. More info needed. – Gemperle