[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] Digest authentication: Stale nonce received
From: |
Mario Valle |
Subject: |
Re: [libmicrohttpd] Digest authentication: Stale nonce received |
Date: |
Thu, 26 Nov 2015 11:01:32 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
Found the problem!
It was in the code extracted from the tutorial regarding serving files.
After checking if the method is GET, it does the following:
if(&aptr != *ptr)
{
/* do never respond on first call */
*ptr = &aptr;
return MHD_YES;
}
*ptr = NULL; /* reset when done */
I don't remember why ignoring the first call had been required in the
first place. But removing these lines makes the Digest authentication
works like a charm.
You can find the complete, still messy, code here:
https://dl.dropboxusercontent.com/u/2571325/server_example.c
Solved this I'm in sight of finishing my project.
See you!
mario
On 25-Nov-15 21:03, Mario Valle wrote:
Dear all,
I just started playing with MHD. With a few contortions, I'm able to use
it on Windows. Very good! Thanks.
My final goal is to embed a server in my application with a modicum of
authentication and very few requests per day :-)
So I opted for Digest authentication.
I started from digest_auth_example.c and added code to serve my html
files and images (ie transplanting the example from the tutorial section
4).
The problem is that the browser (Chrome) is asking for username and
password apparently for each loaded image of the page. Adding few printf
to the digest_auth_example.c code gives:
> server.exe 8899
Before MHD_digest_auth_check
After MHD_digest_auth_check ret: 0
/// Perfect, the first time it asks for user/passwd
Before MHD_digest_auth_check
After MHD_digest_auth_check ret: 1
Continuing and loading url: </index.html>
/// Perfect, it load the page.
/// Now the request for the first image on the page
Before MHD_digest_auth_check
Stale nonce received. If this happens a lot, you should probably
increase the size of the nonce array.
After MHD_digest_auth_check ret: 0
/// Now the browser asks again for user/passwd. So I push cancel on the
form
Well, I have increased the value of MHD_OPTION_NONCE_NC_SIZE from 300 to
50000 and nothing change, so seems the message is a red herring.
I'm deeply ignorant in these auth thingies, so I don't know if I blindly
used the example that works for a single request or there is something
more profound I'm missing.
All your help is highly appreciated. Thanks!
mario
--
Ing. Mario Valle
Swiss National Supercomputing Centre (CSCS)
v. Trevano 131, 6900 Lugano, Switzerland
Tel: +41 (91) 610.82.60