belle_sip_listening_point_t * belle_sip_tls_listening_point_new(belle_sip_stack_t *s, const char *ipaddress, int port){ belle_sip_tls_listening_point_t *lp=belle_sip_object_new(belle_sip_tls_listening_point_t); belle_sip_stream_listening_point_init((belle_sip_stream_listening_point_t*)lp,s,ipaddress,port,on_new_connection); lp->verify_exceptions=0; /*try to load "system" default root ca, wihtout warranty...*/ #ifdef __linux belle_sip_tls_listening_point_set_root_ca(lp,"/etc/ssl/certs"); #elif defined(__APPLE__) belle_sip_tls_listening_point_set_root_ca(lp,"/opt/local/share/curl/curl-ca-bundle.crt"); #endif return BELLE_SIP_LISTENING_POINT(lp); }
int register_init(void) { belle_sip_listening_point_t *lp; stack=belle_sip_stack_new(NULL); lp=belle_sip_stack_create_listening_point(stack,"0.0.0.0",7060,"UDP"); prov=belle_sip_stack_create_provider(stack,lp); lp=belle_sip_stack_create_listening_point(stack,"0.0.0.0",7060,"TCP"); belle_sip_provider_add_listening_point(prov,lp); lp=belle_sip_stack_create_listening_point(stack,"0.0.0.0",7061,"TLS"); if (lp) { /* since test.linphone.org does not have proper certificates, don't verify anything*/ belle_sip_tls_listening_point_set_verify_exceptions(BELLE_SIP_TLS_LISTENING_POINT(lp),BELLE_SIP_TLS_LISTENING_POINT_BADCERT_ANY_REASON); if (belle_sip_tester_get_root_ca_path() != NULL) { belle_sip_tls_listening_point_set_root_ca(BELLE_SIP_TLS_LISTENING_POINT(lp), belle_sip_tester_get_root_ca_path()); } belle_sip_provider_add_listening_point(prov,lp); } listener_callbacks.process_dialog_terminated=process_dialog_terminated; listener_callbacks.process_io_error=process_io_error; listener_callbacks.process_request_event=process_request_event; listener_callbacks.process_response_event=process_response_event; listener_callbacks.process_timeout=process_timeout; listener_callbacks.process_transaction_terminated=process_transaction_terminated; listener_callbacks.process_auth_requested=process_auth_requested; listener_callbacks.listener_destroyed=NULL; listener=belle_sip_listener_create_from_callbacks(&listener_callbacks,NULL); return 0; }
static void set_tls_properties(Sal *ctx){ belle_sip_listening_point_t *lp=belle_sip_provider_get_listening_point(ctx->prov,"TLS"); if (lp){ belle_sip_tls_listening_point_t *tlp=BELLE_SIP_TLS_LISTENING_POINT(lp); int verify_exceptions=0; if (!ctx->tls_verify) verify_exceptions=BELLE_SIP_TLS_LISTENING_POINT_BADCERT_ANY_REASON; else if (!ctx->tls_verify_cn) verify_exceptions=BELLE_SIP_TLS_LISTENING_POINT_BADCERT_CN_MISMATCH; belle_sip_tls_listening_point_set_root_ca(tlp,ctx->root_ca); /*root_ca might be NULL */ belle_sip_tls_listening_point_set_verify_exceptions(tlp,verify_exceptions); } }