Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to get negotiate authentication to work in a libcurl program
    primarykey
    data
    text
    <p>I am currently using <code>libcurl(version 7.19.6 built with SPNEGO and GSS-Negotiate support)</code> to write a client(C++/C) which connects to a protected webpage(<code>Kerberos</code> protected) behind a Tomcat Server. Using the command line:-</p> <pre><code>curl --negotiate -u: http://prtotectedpage.jsp --verbose </code></pre> <p>this works(the server returns an an HTTP 401 unauthorized and then it allows for the <code>SPNEGO</code> tokens to be passed and processed and I get access to the protected page).</p> <p>However when I write the following code and try:- </p> <pre><code>using namespace std; #include &lt;stdio.h&gt; #include &lt;curl.h&gt; #define YOUR_URL "http://protectedpage.jsp" #define ANYUSER "" int main(int argc, char* argv[]) { __asm int 3; //a debugging thing //initialize a curl object CURLcode result; int x; CURL* curl = curl_easy_init(); if(curl){ curl_easy_setopt(curl,CURLOPT_HTTPAUTH, CURLAUTH_GSSNEGOTIATE); curl_easy_setopt(curl,CURLOPT_USERNAME, ANYUSER); curl_easy_setopt(curl,CURLOPT_VERBOSE, 1); curl_easy_setopt(curl, CURLOPT_URL,YOUR_URL); curl_easy_perform(curl); curl_easy_cleanup(curl); } return 0; } </code></pre> <p>I get response from server after initial connection(error 302) which corresponds to the page is temporarily moved. </p> <p>Does anyone know how this might happen.</p> <p>Some other configurations for information (<code>KDC = Windows Active Directory in Windows server 2008</code>), </p> <p><code>curl version(7.19.6)</code> and </p> <pre><code>IDE = (Microsoft visual studio) </code></pre> <p>Ok I have done a little more investigating with wireshark and I found the following differences between their initial requests:-</p> <p>For the command line one(i.e the successful one):-</p> <pre><code>GET /protected.jsp HTTP 1.1 \r\n Host : somecomputername User Agent: curl(7.19.6) (ipc-386-win32) libcurl/7.19.16 OPENSSL/0.9.8K \r\n Accept */*\r\n Full request: [http://somecomputername/protected.jsp] </code></pre> <p>Whereas for the client code(the one I wrote and failed):-</p> <pre><code>GET /protected.jsp HTTP 1.1 \r\n Host : somecomputername Accept */*\r\n Full request: [http://somecomputername/protected.jsp] </code></pre> <p>This would mean that the user agent is not passed in the program. I am still looking into it and some inputs would be much appreciated</p> <p>Second edit:- I made an observation on the verbose output of both:-</p> <p>For the command line version(working one) - </p> <pre><code>&gt; GET /examples/ HTTP/1.1 &gt; User-Agent: curl/7.19.6 (i386-pc-win32) libcurl/7.19.6 OpenSSL/0.9.8k &gt; Host: somecomputer &gt; Accept: */* </code></pre> <p>And for the non working one(the client code I wrote):-</p> <pre><code>&gt; GET /examples HTTP/1.1 Authorization: Basic RGt1bUByMTIzOg== User-Agent: curl/7.19.6 (i386-pc-win32) libcurl/7.19.6 OpenSSL/0.9.8k Host: somecomputer Accept: */* </code></pre> <p>Both of these are the first few lines of the output of the respective .exe files. Now I noticed two things. One the failed one goes to Basic by default. Two (this one is more disturbing), no arrows(>) in the Useragent and host lines in the failed one. Does this mean useragent is never sent?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload