Changeset 849


Ignore:
Timestamp:
Dec 8, 2006 9:58:31 PM (17 years ago)
Author:
bennylp
Message:

Initial implementation of TLS transport for ticket #3 (still not working at all)

Location:
pjproject/trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r839 r849  
    4141    pj_bool_t               no_tcp; 
    4242    pj_bool_t               no_udp; 
     43    pj_bool_t               use_tls; 
    4344    pjsua_transport_config  udp_cfg; 
    4445    pjsua_transport_config  rtp_cfg; 
     
    138139    puts  ("  --use-stun1=host[:port]"); 
    139140    puts  ("  --use-stun2=host[:port]  Resolve local IP with the specified STUN servers"); 
     141#if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0 
     142    puts  ("  --use-tls           Enable TLS transport"); 
     143    puts  ("  --tls-ca-file       Specify TLS CA file"); 
     144    puts  ("  --tls-key-file      Specify TLS client key file"); 
     145    puts  ("  --tls-password      Specify TLS password"); 
     146#endif 
    140147    puts  (""); 
    141148    puts  ("Media Options:"); 
     
    300307           OPT_DURATION, OPT_NO_TCP, OPT_NO_UDP, OPT_THREAD_CNT, 
    301308           OPT_NOREFERSUB, 
     309           OPT_USE_TLS, OPT_TLS_CA_FILE, OPT_TLS_KEY_FILE, OPT_TLS_PASSWORD, 
    302310    }; 
    303311    struct pj_getopt_option long_options[] = { 
     
    354362        { "duration",   1, 0, OPT_DURATION}, 
    355363        { "thread-cnt", 1, 0, OPT_THREAD_CNT}, 
     364        { "use-tls",    0, 0, OPT_USE_TLS},  
     365        { "tls-ca-file",1, 0, OPT_TLS_CA_FILE}, 
     366        { "tls-key-file",1,0, OPT_TLS_KEY_FILE},  
     367        { "tls-password",1,0, OPT_TLS_PASSWORD}, 
    356368        { NULL, 0, 0, 0} 
    357369    }; 
     
    775787            break; 
    776788 
     789        case OPT_USE_TLS: 
     790            cfg->use_tls = PJ_TRUE; 
     791            break; 
     792             
     793        case OPT_TLS_CA_FILE: 
     794            cfg->udp_cfg.tls_ca_file = pj_str(pj_optarg); 
     795            break; 
     796             
     797        case OPT_TLS_KEY_FILE: 
     798            cfg->udp_cfg.tls_key_file = pj_str(pj_optarg); 
     799            break; 
     800             
     801        case OPT_TLS_PASSWORD: 
     802            cfg->udp_cfg.tls_password = pj_str(pj_optarg); 
     803            break; 
     804 
    777805        default: 
    778806            PJ_LOG(1,(THIS_FILE,  
     
    10031031    } 
    10041032 
     1033    /* TLS */ 
     1034    if (config->use_tls) 
     1035        pj_strcat2(&cfg, "--use-tls\n"); 
     1036    if (config->udp_cfg.tls_ca_file.slen) { 
     1037        pj_ansi_sprintf(line, "--tls-ca-file %.*s\n", 
     1038                        (int)config->udp_cfg.tls_ca_file.slen,  
     1039                        config->udp_cfg.tls_ca_file.ptr); 
     1040        pj_strcat2(&cfg, line); 
     1041    } 
     1042    if (config->udp_cfg.tls_key_file.slen) { 
     1043        pj_ansi_sprintf(line, "--tls-key-file %.*s\n", 
     1044                        (int)config->udp_cfg.tls_key_file.slen,  
     1045                        config->udp_cfg.tls_key_file.ptr); 
     1046        pj_strcat2(&cfg, line); 
     1047    } 
     1048    if (config->udp_cfg.tls_password.slen) { 
     1049        pj_ansi_sprintf(line, "--tls-password %.*s\n", 
     1050                        (int)config->udp_cfg.tls_password.slen,  
     1051                        config->udp_cfg.tls_password.ptr); 
     1052        pj_strcat2(&cfg, line); 
     1053    } 
    10051054 
    10061055    pj_strcat2(&cfg, "\n#\n# Media settings:\n#\n"); 
     
    27652814    } 
    27662815 
    2767  
    27682816    /* Add UDP transport unless it's disabled. */ 
    27692817    if (!app_config.no_udp) { 
     
    27782826        pjsua_acc_set_online_status(current_acc, PJ_TRUE); 
    27792827    } 
     2828 
     2829#if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0 
     2830    /* Add TLS transport when application wants one */ 
     2831    if (app_config.use_tls) { 
     2832        status = pjsua_transport_create(PJSIP_TRANSPORT_TLS, 
     2833                                        &app_config.udp_cfg,  
     2834                                        &transport_id); 
     2835        if (status != PJ_SUCCESS) 
     2836            goto on_error; 
     2837    } 
     2838#endif 
    27802839 
    27812840    if (transport_id == -1) { 
  • pjproject/trunk/pjsip/build/pjsip_core.dsp

    r554 r849  
    151151# Begin Source File 
    152152 
     153SOURCE=..\src\pjsip\sip_transport_tls_ossl.c 
     154# End Source File 
     155# Begin Source File 
     156 
    153157SOURCE=..\src\pjsip\sip_transport_udp.c 
    154158# End Source File 
     
    287291# Begin Source File 
    288292 
     293SOURCE=..\include\pjsip\sip_transport_tls.h 
     294# End Source File 
     295# Begin Source File 
     296 
    289297SOURCE=..\include\pjsip\sip_transport_udp.h 
    290298# End Source File 
  • pjproject/trunk/pjsip/include/pjsip.h

    r563 r849  
    4141#include <pjsip/sip_transport_loop.h> 
    4242#include <pjsip/sip_transport_tcp.h> 
     43#if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0 
     44#   include <pjsip/sip_transport_tls.h> 
     45#endif 
    4346#include <pjsip/sip_resolve.h> 
    4447 
  • pjproject/trunk/pjsip/include/pjsip/sip_config.h

    r753 r849  
    232232#ifndef PJSIP_MAX_RESOLVED_ADDRESSES 
    233233#   define PJSIP_MAX_RESOLVED_ADDRESSES     8 
     234#endif 
     235 
     236 
     237/** 
     238 * Enable TLS SIP transport support. For most systems this means that 
     239 * OpenSSL must be installed. 
     240 * 
     241 * Default: 0 (for now) 
     242 */ 
     243#ifndef PJSIP_HAS_TLS_TRANSPORT 
     244#   define PJSIP_HAS_TLS_TRANSPORT          0 
    234245#endif 
    235246 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r823 r849  
    840840     */ 
    841841    pjsua_stun_config   stun_config; 
     842 
     843    /** 
     844     * TLS root CA file path (only used for TLS transport). 
     845     */ 
     846    pj_str_t            tls_ca_file; 
     847 
     848    /** 
     849     * TLS client key path (only used for TLS transport). 
     850     */ 
     851    pj_str_t            tls_key_file; 
     852 
     853    /** 
     854     * TLS password (only used for TLS transport). 
     855     */ 
     856    pj_str_t            tls_password; 
    842857 
    843858} pjsua_transport_config; 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r839 r849  
    10451045        pjsua_var.tpdata[id].data.factory = tcp; 
    10461046 
     1047#if defined(PJSIP_HAS_TLS_TRANSPORT) && PJSIP_HAS_TLS_TRANSPORT!=0 
     1048    } else if (type == PJSIP_TRANSPORT_TLS) { 
     1049        /* 
     1050         * Create TLS transport. 
     1051         */ 
     1052        pjsip_tpfactory *tls; 
     1053 
     1054        status = pjsip_tls_transport_start(pjsua_var.endpt,  
     1055                                           &cfg->tls_key_file, 
     1056                                           &cfg->tls_password,  
     1057                                           &cfg->tls_ca_file, 
     1058                                           NULL, NULL, 1, &tls); 
     1059        if (status != PJ_SUCCESS) { 
     1060            pjsua_perror(THIS_FILE, "Error creating SIP TLS listener",  
     1061                         status); 
     1062            goto on_return; 
     1063        } 
     1064 
     1065        /* Save the transport */ 
     1066        pjsua_var.tpdata[id].type = type; 
     1067        pjsua_var.tpdata[id].local_name = tls->addr_name; 
     1068        pjsua_var.tpdata[id].data.factory = tls; 
     1069#endif 
     1070 
    10471071    } else { 
    10481072        status = PJSIP_EUNSUPTRANSPORT; 
Note: See TracChangeset for help on using the changeset viewer.