- Timestamp:
- Dec 28, 2016 3:40:07 AM (8 years ago)
- Location:
- pjproject/branches/projects/uwp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/uwp
- Property svn:mergeinfo changed
/pjproject/trunk (added) merged: 5209,5212-5234,5237-5253,5255,5257-5292,5294-5297,5299-5332,5334-5394,5396-5438,5440-5469,5471-5496,5498-5510
- Property svn:mergeinfo changed
-
pjproject/branches/projects/uwp/pjsip/src/pjsip/sip_auth_client.c
r4728 r5513 340 340 else { 341 341 pjsip_auth_create_digest( &cred->response, &cred->nonce, 342 &cred->nc, cnonce, &pjsip_AUTH_STR,342 &cred->nc, &cred->cnonce, &pjsip_AUTH_STR, 343 343 uri, &chal->realm, cred_info, method ); 344 344 } … … 358 358 * Update authentication session with a challenge. 359 359 */ 360 static void update_digest_session( pj_pool_t *ses_pool, 361 pjsip_cached_auth *cached_auth, 360 static void update_digest_session( pjsip_cached_auth *cached_auth, 362 361 const pjsip_www_authenticate_hdr *hdr ) 363 362 { … … 366 365 if (!cached_auth->last_chal || pj_stricmp2(&hdr->scheme, "digest")) { 367 366 cached_auth->last_chal = (pjsip_www_authenticate_hdr*) 368 pjsip_hdr_clone( ses_pool, hdr);367 pjsip_hdr_clone(cached_auth->pool, hdr); 369 368 } else { 370 369 /* Only update if the new challenge is "significantly different" … … 383 382 { 384 383 cached_auth->last_chal = (pjsip_www_authenticate_hdr*) 385 pjsip_hdr_clone(ses_pool, hdr);384 pjsip_hdr_clone(cached_auth->pool, hdr); 386 385 } 387 386 } … … 394 393 /* Save the whole challenge */ 395 394 cached_auth->last_chal = (pjsip_www_authenticate_hdr*) 396 pjsip_hdr_clone( ses_pool, hdr);395 pjsip_hdr_clone(cached_auth->pool, hdr); 397 396 398 397 /* Create cnonce */ 399 pj_create_unique_string( ses_pool, &cached_auth->cnonce );398 pj_create_unique_string( cached_auth->pool, &cached_auth->cnonce ); 400 399 401 400 /* Initialize nonce-count */ … … 407 406 */ 408 407 if (cached_auth->realm.slen == 0) { 409 pj_strdup( ses_pool, &cached_auth->realm,408 pj_strdup(cached_auth->pool, &cached_auth->realm, 410 409 &hdr->challenge.digest.realm); 411 410 } … … 420 419 } else { 421 420 /* Server gives new nonce. */ 422 pj_strdup(ses_pool, &cached_auth->last_chal->challenge.digest.nonce, 421 pj_strdup(cached_auth->pool, 422 &cached_auth->last_chal->challenge.digest.nonce, 423 423 &hdr->challenge.digest.nonce); 424 424 /* Has the opaque changed? */ … … 426 426 &hdr->challenge.digest.opaque)) 427 427 { 428 pj_strdup( ses_pool,428 pj_strdup(cached_auth->pool, 429 429 &cached_auth->last_chal->challenge.digest.opaque, 430 430 &hdr->challenge.digest.opaque); … … 495 495 sess->cred_info = NULL; 496 496 pj_list_init(&sess->cached_auth); 497 498 return PJ_SUCCESS; 499 } 500 501 502 /* Deinit client session. */ 503 PJ_DEF(pj_status_t) pjsip_auth_clt_deinit(pjsip_auth_clt_sess *sess) 504 { 505 pjsip_cached_auth *auth; 506 507 PJ_ASSERT_RETURN(sess && sess->endpt, PJ_EINVAL); 508 509 auth = sess->cached_auth.next; 510 while (auth != &sess->cached_auth) { 511 pjsip_endpt_release_pool(sess->endpt, auth->pool); 512 auth = auth->next; 513 } 497 514 498 515 return PJ_SUCCESS; … … 692 709 { 693 710 if (cached_auth) { 694 update_digest_session( sess_pool,cached_auth, hdr );711 update_digest_session( cached_auth, hdr ); 695 712 696 713 cnonce = &cached_auth->cnonce; … … 961 978 } 962 979 980 981 static void recreate_cached_auth_pool( pjsip_endpoint *endpt, 982 pjsip_cached_auth *auth ) 983 { 984 pj_pool_t *auth_pool = pjsip_endpt_create_pool(endpt, "auth_cli%p", 1024, 985 1024); 986 987 if (auth->realm.slen) { 988 pj_str_t realm; 989 pj_strdup(auth_pool, &realm, &auth->realm); 990 pj_strassign(&auth->realm, &realm); 991 } 992 993 if (auth->cnonce.slen) { 994 pj_str_t cnonce; 995 pj_strdup(auth_pool, &cnonce, &auth->cnonce); 996 pj_strassign(&auth->cnonce, &cnonce); 997 } 998 999 if (auth->last_chal) { 1000 auth->last_chal = (pjsip_www_authenticate_hdr*) 1001 pjsip_hdr_clone(auth_pool, auth->last_chal); 1002 } 1003 1004 pjsip_endpt_release_pool(endpt, auth->pool); 1005 auth->pool = auth_pool; 1006 } 963 1007 964 1008 /* Process authorization challenge */ … … 1127 1171 break; 1128 1172 1129 hchal = (const pjsip_www_authenticate_hdr*) 1173 hchal = (const pjsip_www_authenticate_hdr*)hdr; 1130 1174 ++chal_cnt; 1131 1175 … … 1133 1177 * if not present. 1134 1178 */ 1135 cached_auth = find_cached_auth(sess, &hchal->challenge.common.realm 1179 cached_auth = find_cached_auth(sess, &hchal->challenge.common.realm); 1136 1180 if (!cached_auth) { 1137 cached_auth = PJ_POOL_ZALLOC_T( sess->pool, pjsip_cached_auth); 1138 pj_strdup( sess->pool, &cached_auth->realm, &hchal->challenge.common.realm); 1181 cached_auth = PJ_POOL_ZALLOC_T(sess->pool, pjsip_cached_auth); 1182 cached_auth->pool = pjsip_endpt_create_pool(sess->endpt, 1183 "auth_cli%p", 1184 1024, 1185 1024); 1186 pj_strdup(cached_auth->pool, &cached_auth->realm, 1187 &hchal->challenge.common.realm); 1139 1188 cached_auth->is_proxy = (hchal->type == PJSIP_H_PROXY_AUTHENTICATE); 1140 1189 # if (PJSIP_AUTH_HEADER_CACHING) … … 1143 1192 } 1144 1193 # endif 1145 pj_list_insert_before( &sess->cached_auth, cached_auth);1194 pj_list_insert_before(&sess->cached_auth, cached_auth); 1146 1195 } 1147 1196 … … 1149 1198 * authorization session. 1150 1199 */ 1151 status = process_auth( 1152 1200 status = process_auth(tdata->pool, hchal, tdata->msg->line.req.uri, 1201 tdata, sess, cached_auth, &hauth); 1153 1202 if (status != PJ_SUCCESS) 1154 1203 return status; 1204 1205 if (pj_pool_get_used_size(cached_auth->pool) > 1206 PJSIP_AUTH_CACHED_POOL_MAX_SIZE) 1207 { 1208 recreate_cached_auth_pool(sess->endpt, cached_auth); 1209 } 1155 1210 1156 1211 /* Add to the message. */
Note: See TracChangeset
for help on using the changeset viewer.