Changeset 6055


Ignore:
Timestamp:
Aug 28, 2019 2:13:32 PM (5 years ago)
Author:
riza
Message:

Close #2222: Introduce a new compiler setting to allow to use cnonce for SIP authentication without hyphen character

Location:
pjproject/trunk/pjsip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_config.h

    r6002 r6055  
    11911191#endif 
    11921192 
     1193 
     1194/** 
     1195 * Specify whether the cnonce used for SIP authentication contain digits only. 
     1196 * The "cnonce" value is setup using GUID generator, i.e: 
     1197 * pj_create_unique_string(), and the GUID string may contain hyphen character 
     1198 * ("-"). Some SIP servers do not like this GUID format, so this option will 
     1199 * strip any hyphens from the GUID string. 
     1200 * 
     1201 * Default is 1 (cnonce will not contain any hyphen characters). 
     1202 */ 
     1203#ifndef PJSIP_AUTH_CNONCE_USE_DIGITS_ONLY 
     1204#   define PJSIP_AUTH_CNONCE_USE_DIGITS_ONLY    1 
     1205#endif 
     1206 
    11931207/***************************************************************************** 
    11941208 *  SIP Event framework and presence settings. 
  • pjproject/trunk/pjsip/src/pjsip/sip_auth_client.c

    r5883 r6055  
    397397        /* Create cnonce */ 
    398398        pj_create_unique_string( cached_auth->pool, &cached_auth->cnonce ); 
     399#if defined(PJSIP_AUTH_CNONCE_USE_DIGITS_ONLY) && \ 
     400    PJSIP_AUTH_CNONCE_USE_DIGITS_ONLY!=0 
     401        if (pj_strchr(&cached_auth->cnonce, '-')) { 
     402            /* remove hyphen character. */ 
     403            int w, r, len = pj_strlen(&cached_auth->cnonce); 
     404            char *s = cached_auth->cnonce.ptr; 
     405 
     406            w = r = 0; 
     407            for (; r < len; r++) { 
     408                if (s[r] != '-') 
     409                    s[w++] = s[r]; 
     410            } 
     411            s[w] = '\0'; 
     412            cached_auth->cnonce.slen = w; 
     413        } 
     414#endif 
    399415 
    400416        /* Initialize nonce-count */ 
Note: See TracChangeset for help on using the changeset viewer.