Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 998551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:12:51+00:00 2026-05-16T07:12:51+00:00

I have an app that communicates with a server that uses HTTP Digest authentication.

  • 0

I have an app that communicates with a server that uses HTTP Digest authentication.

It seems to me that the ‘session’ management within the iPhone is pretty “black box” to us developers. Is it true that we can’t see how the framework handles / persists http sessions?

If I’m just being dim here, would someone care to explain how to probably handle HTTP Digest authentication on the iPhone?

My basic run through is:

  • Make a request to a secured url
  • Server sends a 401
  • client creates and persists a credential, and passes it back to the server
  • server verifies credential, completes request if verified, sends another 401 if not.
  • make a subsequent request to secure url
  • server requests authorisation again……..

This works for single requests, but if I make additional, subsequent requests, the server requests authorisation again. The server has persisted a session for the particular user, but the iPhone isn’t making a request within the same session for some reason… Therefore, the server has to throw out the authentication object and create a new one each time the client makes a request to a secured url.

I’m sure this isn’t correct behaviour.

If we look at how a browser behaves in this situation:

  • Browser requests data from secure url
  • server sends 401
  • browser prompts user for credential, persists it, passes it to server
  • server verifies credential, returning data if verified, sends another 401 if not.
  • subsequent requests made to secure urls are not prompted for credentials because the browser manages the session.

I’m creating the NSURLCredential and persisting it within the NSURLCrendtialStorage.
Then when the app receives the ‘didReceiveAuthenticationChallenge’ I retrieve the credential from the storage and pass it back, creating the credential if it doesn’t exist (on the first request).

Any help would be greatly appreciated.
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:12:51+00:00Added an answer on May 16, 2026 at 7:12 am

    First thing, is to forget about HTTP sessions, as these do not interact with Digest authentication active log-ins (there is a sort of session info ability, but it’s different).

    Indeed, one of the main reasons for using Digest, is to not have to use sessions just to maintain a logged-in state. Sessions are heavy and hurt scalability.

    I couldn’t say for sure what your issue is, but I do know what I would check on first, which is correct use of stale and correct creation of nonces.

    User-agents can only handle authentication without requerying the user if they are asked to handle the same nonce, or in another case I will come to later (easier to explain it in this order).

    If you have the same nonce used in each request, then the user-agent will continue to use it along with the “ha1” from the user/pass to request subsequent resources. This is done preëmptively, so the challenge never happens.

    Of course, using the same nonce introduces an element of insecurity, as replay attacks become trivial to anyone that can sniff the traffic. Nonces will have to change on a regular basis.

    Hence, if you receive a request from a user-agent with an invalid Authorization header, but the reason it is invalid is that the nonce is wrong (it’s using an expired one) then in your challenge include “stale=true” (defaults to false). This informs the user-agent that your reason for rejecting is the nonce is outdated (of course the other information may also be wrong, but that doesn’t matter as you aren’t going to let it play either way).

    On receiving such a stale=true the user-agent will know that it isn’t authorised, but instead of requerying the user (or throwing an exception if it’s a UI-less component) will retry the old criteria with the new nonce.

    I can’t tell if any of this is what’s affecting you, but the way nonces and staleness are determined and signalled is certainly the first thing I’d look at.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.