Ignore:
Timestamp:
Dec 29, 2006 12:13:10 AM (17 years ago)
Author:
bennylp
Message:

Fixed ticket #25: Authentication loops forever when server keeps rejecting request with stale=true

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_auth_client.c

    r696 r871  
    4444#endif 
    4545 
     46 
    4647/* Transform digest to string. 
    4748 * output must be at least PJSIP_MD5STRLEN+1 bytes. 
     
    600601    auth = sess->cached_auth.next; 
    601602    while (auth != &sess->cached_auth) { 
     603        /* Reset stale counter */ 
     604        auth->stale_cnt = 0; 
     605 
    602606        if (auth->qop_value == PJSIP_AUTH_QOP_NONE) { 
    603607#           if defined(PJSIP_AUTH_HEADER_CACHING) && \ 
     
    708712             * the same credential. 
    709713             */ 
    710             PJ_LOG(4, (THIS_FILE, "Authorization failed for %.*s@%.*s", 
     714            PJ_LOG(4, (THIS_FILE, "Authorization failed for %.*s@%.*s: " 
     715                       "server rejected with stale=false", 
    711716                       sent_auth->credential.digest.username.slen, 
    712717                       sent_auth->credential.digest.username.ptr, 
     
    714719                       sent_auth->credential.digest.realm.ptr)); 
    715720            return PJSIP_EFAILEDCREDENTIAL; 
     721        } 
     722 
     723        cached_auth->stale_cnt++; 
     724        if (cached_auth->stale_cnt >= PJSIP_MAX_STALE_COUNT) { 
     725            /* Our credential is rejected. No point in trying to re-supply 
     726             * the same credential. 
     727             */ 
     728            PJ_LOG(4, (THIS_FILE, "Authorization failed for %.*s@%.*s: " 
     729                       "maximum number of stale retries exceeded", 
     730                       sent_auth->credential.digest.username.slen, 
     731                       sent_auth->credential.digest.username.ptr, 
     732                       sent_auth->credential.digest.realm.slen, 
     733                       sent_auth->credential.digest.realm.ptr)); 
     734            return PJSIP_EAUTHSTALECOUNT; 
    716735        } 
    717736 
Note: See TracChangeset for help on using the changeset viewer.