Ignore:
Timestamp:
Feb 27, 2014 6:16:36 AM (9 years ago)
Author:
nanang
Message:

Fixed #1740: TLS will be used whenever request URI uses "sips" scheme regardless the target-URI scheme/transport. This behavior is configurable via 'PJSIP_DONT_SWITCH_TO_TLS' in compile-time, or 'pjsip_cfg()->disable_tls_switch' in run-time.

File:
1 edited

Legend:

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

    r4537 r4770  
    803803/* Fill-up destination information from a target URI */ 
    804804static pj_status_t get_dest_info(const pjsip_uri *target_uri,  
     805                                 const pjsip_uri *request_uri,  
    805806                                 pj_pool_t *pool, 
    806807                                 pjsip_host_info *dest_info) 
     
    811812    pj_bzero(dest_info, sizeof(*dest_info)); 
    812813 
    813     if (PJSIP_URI_SCHEME_IS_SIPS(target_uri)) { 
     814    /* When request URI uses sips scheme, TLS must always be used regardless 
     815     * of the target scheme or transport type (see ticket #1740). 
     816     */ 
     817    if (PJSIP_URI_SCHEME_IS_SIPS(target_uri) ||  
     818        (pjsip_cfg()->endpt.disable_tls_switch == 0 && request_uri && 
     819         PJSIP_URI_SCHEME_IS_SIPS(request_uri))) 
     820    { 
    814821        pjsip_uri *uri = (pjsip_uri*) target_uri; 
    815822        const pjsip_sip_uri *url=(const pjsip_sip_uri*)pjsip_uri_get_uri(uri); 
    816823        unsigned flag; 
     824 
     825        if (!PJSIP_URI_SCHEME_IS_SIPS(target_uri)) { 
     826            PJ_LOG(4,(THIS_FILE, "Automatic switch to TLS transport as " 
     827                                 "request-URI uses ""sips"" scheme.")); 
     828        } 
    817829 
    818830        dest_info->flag |= (PJSIP_TRANSPORT_SECURE | PJSIP_TRANSPORT_RELIABLE); 
     
    896908    } 
    897909 
    898     return get_dest_info(target_uri, (pj_pool_t*)tdata->pool, dest_info); 
     910    return get_dest_info(target_uri, tdata->msg->line.req.uri, 
     911                         (pj_pool_t*)tdata->pool, dest_info); 
    899912} 
    900913 
     
    9991012 
    10001013    /* Fill up the destination host/port from the URI. */ 
    1001     status = get_dest_info(target_uri, tdata->pool, dest_info); 
     1014    status = get_dest_info(target_uri, new_request_uri, tdata->pool, 
     1015                           dest_info); 
    10021016    if (status != PJ_SUCCESS) 
    10031017        return status; 
     
    14961510 
    14971511    /* Build destination info. */ 
    1498     status = get_dest_info(uri, tdata->pool, &dest_info); 
     1512    status = get_dest_info(uri, NULL, tdata->pool, &dest_info); 
    14991513    if (status != PJ_SUCCESS) { 
    15001514        pjsip_tx_data_dec_ref(tdata); 
Note: See TracChangeset for help on using the changeset viewer.