Commit 18d21119 authored by jehan's avatar jehan
Browse files

add tls certificates tester

parent 8e124bc7
......@@ -358,15 +358,16 @@ static void process_sdp_for_invite(SalOp* op,belle_sip_request_t* invite) {
}
static void process_request_event(void *op_base, const belle_sip_request_event_t *event) {
SalOp* op = (SalOp*)op_base;
belle_sip_server_transaction_t* server_transaction = belle_sip_provider_create_server_transaction(op->base.root->prov,belle_sip_request_event_get_request(event));
belle_sip_server_transaction_t* server_transaction=NULL;
belle_sdp_session_description_t* sdp;
belle_sip_request_t* req = belle_sip_request_event_get_request(event);
belle_sip_dialog_state_t dialog_state;
belle_sip_response_t* resp;
belle_sip_header_t* call_info;
if (server_transaction){
belle_sip_object_ref(server_transaction); /*ACK does'nt create srv transaction*/
if (strcmp("ACK",belle_sip_request_get_method(req))!=0){ /*ACK does'nt create srv transaction*/
server_transaction = belle_sip_provider_create_server_transaction(op->base.root->prov,belle_sip_request_event_get_request(event));
belle_sip_object_ref(server_transaction);
belle_sip_transaction_set_application_data(BELLE_SIP_TRANSACTION(server_transaction),op);
sal_op_ref(op);
}
......
......@@ -44,7 +44,7 @@ transports=sip:127.0.0.1:5060 sips:127.0.0.1:5061
# Default value: /etc/flexisip/tls
#tls-certificates-dir=/etc/flexisip/tls
#tls-certificates-dir=/media/sf_workspaces/workspace-macosx/flexisip
tls-certificates-dir=/Users/jehanmonnier/workspaces/workspace-macosx/flexisip
tls-certificates-dir=/Users/jehanmonnier/workspaces/workspace-sip-parser/linphone-private/tester/certificates
##
## STUN server parameters.
......
......@@ -108,13 +108,16 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c
char filepath[256];
char ringpath[256];
char ringbackpath[256];
char rootcapath[256];
sprintf(filepath, "%s/%s", path, file);
lc = linphone_core_new(v_table,NULL,filepath,NULL);
linphone_core_set_user_data(lc,&global_stat);
counters = (stats*)linphone_core_get_user_data(lc);
/* until we have good certificates on our test server... */
linphone_core_verify_server_certificates(lc,FALSE);
/* until we have good certificates on our test server...
linphone_core_verify_server_certificates(lc,FALSE);*/
sprintf(rootcapath, "%s/certificates/cacert.pem", path);
linphone_core_set_root_ca(lc,rootcapath);
sprintf(ringpath, "%s/%s", path, "oldphone.wav");
sprintf(ringbackpath, "%s/%s", path, "ringback.wav");
......@@ -122,7 +125,7 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c
linphone_core_set_ringback(lc, ringbackpath);
reset_counters(counters);
CU_ASSERT_EQUAL(ms_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count);
/*CU_ASSERT_EQUAL(ms_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count);*/
while (counters->number_of_LinphoneRegistrationOk<proxy_count && retry++ <20) {
linphone_core_iterate(lc);
......
......@@ -29,7 +29,7 @@ passwd=secret
realm="sip.example.org"
[proxy_0]
reg_proxy=sip.example.org;transport=tls
reg_proxy=sip2.linphone.org;transport=tls
reg_identity=sip:pauline@sip.example.org
reg_expires=3600
reg_sendregister=1
......
......@@ -14,8 +14,8 @@ realm="sip.example.org"
[proxy_0]
reg_proxy=sip.example.org;transport=tls
reg_route=sip.example.org;transport=tls;lr
reg_proxy=sip2.linphone.org;transport=tls
reg_route=sip2.linphone.org;transport=tls
reg_identity=sip:pauline@sip.example.org
reg_expires=3600
reg_sendregister=1
......
......@@ -354,11 +354,68 @@ static void io_recv_error(){
}
static void tls_certificate_failure(){
LinphoneCoreVTable v_table;
LinphoneCore* lc;
stats stat;
stats* counters;
char rootcapath[256];
memset (&v_table,0,sizeof(v_table));
reset_counters(&stat);
v_table.registration_state_changed=registration_state_changed;
lc = configure_lc_from(&v_table,liblinphone_tester_file_prefix, "pauline_rc", 0);
linphone_core_set_user_data(lc,&stat);
counters = (stats*)linphone_core_get_user_data(lc);
sprintf(rootcapath, "%s/certificates/agent.pem", liblinphone_tester_file_prefix); /*bad root ca*/
linphone_core_set_root_ca(lc,rootcapath);
linphone_core_set_network_reachable(lc,TRUE);
CU_ASSERT_TRUE(wait_for(lc,lc,&stat.number_of_LinphoneRegistrationFailed,1));
linphone_core_set_root_ca(lc,NULL); /*no root ca*/
linphone_core_refresh_registers(lc);
CU_ASSERT_TRUE(wait_for(lc,lc,&stat.number_of_LinphoneRegistrationFailed,2));
sprintf(rootcapath, "%s/certificates/cacert.pem", liblinphone_tester_file_prefix); /*goot root ca*/
linphone_core_set_root_ca(lc,rootcapath);
linphone_core_refresh_registers(lc);
CU_ASSERT_TRUE(wait_for(lc,lc,&stat.number_of_LinphoneRegistrationOk,1));
CU_ASSERT_EQUAL(stat.number_of_LinphoneRegistrationFailed,2);
linphone_core_destroy(lc);
}
/*
static void tls_with_non_tls_server(){
LinphoneCoreVTable v_table;
LinphoneCore* lc;
stats stat;
stats* counters;
LinphoneProxyConfig* proxy_cfg;
LinphoneAddress* addr;
char tmp[256];
memset (&v_table,0,sizeof(v_table));
reset_counters(&stat);
v_table.registration_state_changed=registration_state_changed;
lc = configure_lc_from(&v_table,liblinphone_tester_file_prefix, "marie_rc", 0);
linphone_core_set_user_data(lc,&stat);
counters = (stats*)linphone_core_get_user_data(lc);
linphone_core_get_default_proxy(lc,&proxy_cfg);
linphone_proxy_config_edit(proxy_cfg);
addr=linphone_address_new(linphone_proxy_config_get_addr(proxy_cfg));
snprintf(tmp,sizeof(tmp),"sip:%s:%i;transport=tls" ,linphone_address_get_domain(addr)
,linphone_address_get_port_int(addr));
linphone_proxy_config_set_server_addr(proxy_cfg,tmp);
linphone_proxy_config_done(proxy_cfg);
linphone_address_destroy(addr);
CU_ASSERT_TRUE(wait_for(lc,lc,&stat.number_of_LinphoneRegistrationFailed,1));
linphone_core_destroy(lc);
}*/
test_t register_tests[] = {
{ "Simple register", simple_register },
{ "TCP register", simple_tcp_register },
{ "TCP register compatibility mode", simple_tcp_register_compatibility_mode },
{ "TLS register", simple_tls_register },
{ "TLS certificate not verified",tls_certificate_failure},
/* { "TLS with non tls server",tls_with_non_tls_server},*/
{ "Simple authenticated register", simple_authenticated_register },
{ "Ha1 authenticated register", ha1_authenticated_register },
{ "Digest auth without initial credentials", authenticated_register_with_no_initial_credentials },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment