Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl - SPNEGO cannot find mechanisms to negotiate

i'm trying to use php-curl with a microsoft web service: Here is my code (working on windows 10 with wamp):

<?php

$location = "http://10.0.100.19:7058/FOLDER12013/OData/Company('TEST')/WS_Clienti";
$handle = curl_init($location);

$credentials = 'CPGNET\username:password';
$action =


$proxy =  '11.22.33.44:8123';
$headers = [
    'Method: GET',
    'User-Agent: PHP-SOAP-CURL',
    'Content-Type: text/xml; charset=utf-8',
];


// Authentication
curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_NTLM | CURLAUTH_BASIC | CURLAUTH_GSSNEGOTIATE | CURLAUTH_ANY);
curl_setopt($handle, CURLOPT_USERPWD, $credentials);

curl_setopt($handle, CURLINFO_HEADER_OUT, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($handle, CURLOPT_PROXY,$proxy);

$response = "";
echo("<pre>");
$response = curl_exec($handle);

$url_info = curl_getinfo($handle);

print_r($url_info);

echo(htmlentities($response));
echo("</pre>");

When I try to use this code from centos 7 (or ubuntu 15) I have an error 401 unautorized. Php, curl, libcurl have the same version on windows and linux (and all extensions are equal checking with phpinfo). So, I'm trying to use curl from linux:

curl --negotiate -u "CPGNET\username:password" --proxy 11.22.33.44:8123 "http://10.0.100.19:7058/FOLDER12013/OData/Company('TEST')/WS_Clienti" -v

But I have an error:

* gss_init_sec_context() failed: : SPNEGO cannot find mechanisms to negotiate

Please someone can help me. I don't understand why from linux this not works. Thank you

like image 692
Marco Marino Avatar asked Aug 12 '15 08:08

Marco Marino


1 Answers

a bit old question, but ...

It could be you are hitting a problem with a ntlm authentication via gssapi of curl. Please take a look to following links:

  • Linux related:
    https://github.com/curl/curl/issues/876
  • Windows related:
    https://github.com/curl/curl/issues/980
like image 171
silvio Avatar answered Sep 18 '22 21:09

silvio