]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6287
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 4 Apr 2014 18:42:05 +0000 (13:42 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 4 Apr 2014 18:42:29 +0000 (13:42 -0500)
libs/sofia-sip/libsofia-sip-ua/iptsec/auth_client.c
libs/sofia-sip/libsofia-sip-ua/nua/nua_client.c

index 8a1c0f07ae384c5b2dd574bbb6c7122ece464ecc..a2e2c192209bc7316200a4f9b326bf742dbbb310 100644 (file)
@@ -185,6 +185,10 @@ int ca_challenge(auth_client_t *ca,
 
   if (ca->ca_auc->auc_challenge)
     stale = ca->ca_auc->auc_challenge(ca, ch);
+
+  if (AUTH_CLIENT_IS_EXTENDED(ca))
+         ca->ca_clear = 0;
+
   if (stale < 0)
     return -1;
 
@@ -863,7 +867,7 @@ static int auc_digest_challenge(auth_client_t *ca, msg_auth_t const *ch)
 
   stale = ac->ac_stale || cda->cda_ac->ac_nonce == NULL;
 
-  if (ac->ac_qop && (cda->cda_cnonce == NULL || ac->ac_stale)) {
+  if (ac->ac_qop && (cda->cda_cnonce == NULL || ac->ac_stale || ca->ca_clear )) {
     su_guid_t guid[1];
     char *cnonce;
     size_t b64len = BASE64_MINSIZE(sizeof(guid)) + 1;
index 98b80fc9389384b119f733dc7267db56f9576509..d9d09536acf04e7423ffd28eb6b60325f033f180 100644 (file)
@@ -1178,6 +1178,14 @@ int nua_base_client_check_restart(nua_client_request_t *cr,
     }
   }
 
+  if (status == 403) {
+         if (nh->nh_auth) {
+                 /* Bad username/password */
+                 SU_DEBUG_7(("nua(%p): bad credentials, clearing them\n", (void *)nh));
+                 auc_clear_credentials(&nh->nh_auth, NULL, NULL);
+         }
+  }
+
   if ((status == 401 && sip->sip_www_authenticate) ||
       (status == 407 && sip->sip_proxy_authenticate)) {
     int server = 0, proxy = 0;
@@ -1197,7 +1205,11 @@ int nua_base_client_check_restart(nua_client_request_t *cr,
 
       cr->cr_challenged = 1;
 
-      if (!invalid && auc_has_authorization(&nh->nh_auth)) {
+      if (invalid) {
+                 /* Bad username/password */
+                 SU_DEBUG_7(("nua(%p): bad credentials, clearing them\n", (void *)nh));
+                 auc_clear_credentials(&nh->nh_auth, NULL, NULL);
+      } else if (auc_has_authorization(&nh->nh_auth)) {
                  return nua_client_restart(cr, 100, "Request Authorized by Cache");
          }
 
@@ -1209,7 +1221,7 @@ int nua_base_client_check_restart(nua_client_request_t *cr,
       cr->cr_status = 0, cr->cr_phrase = NULL;
       nua_client_request_unref(cr);
 
-      return !invalid;
+      return 1;
     }
   }
   /* GriGiu : RFC-3261 status supported Retry-After */