From: RĂ©mi Denis-Courmont Date: Sat, 6 Nov 2004 10:49:21 +0000 (+0000) Subject: Fix to use TLS module dynamically X-Git-Tag: 0.8.1~57 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c5d256a11e4d89b223d92f079278306a1004ede3;p=vlc Fix to use TLS module dynamically --- diff --git a/modules/control/http.c b/modules/control/http.c index 0a2642d0e0..0e8b754169 100644 --- a/modules/control/http.c +++ b/modules/control/http.c @@ -190,6 +190,7 @@ struct intf_sys_t playlist_t *p_playlist; input_thread_t *p_input; vlm_t *p_vlm; + tls_t *p_tls; }; @@ -236,13 +237,27 @@ static int Open( vlc_object_t *p_this ) if ( psz_cert != NULL ) { const char *psz_pem; + + p_sys->p_tls = vlc_object_create( p_this, VLC_OBJECT_TLS ); + vlc_object_attach( p_sys->p_tls, p_this ); + + p_sys->p_tls->p_module = module_Need( p_sys->p_tls, "tls", 0, 0 ); + if( p_sys->p_tls->p_module == NULL ) + { + msg_Err( p_this, "cannot find TLS/SSL provider" ); + vlc_object_detach( p_sys->p_tls ); + vlc_object_destroy( p_sys->p_tls ); + p_sys->p_tls = NULL; + return VLC_EGENERIC; + } + msg_Dbg( p_intf, "enablind TLS for HTTP interface (cert file: %s)", psz_cert ); psz_pem = config_GetPsz( p_intf, "http-intf-key" ); if ( psz_pem == NULL ) psz_pem = psz_cert; - p_tls = tls_ServerCreate( VLC_OBJECT(p_intf), psz_cert, psz_pem ); + p_tls = tls_ServerCreate( p_sys->p_tls, psz_cert, psz_pem ); if ( p_tls == NULL ) { msg_Err( p_intf, "TLS initialization error" ); @@ -273,6 +288,7 @@ static int Open( vlc_object_t *p_this ) } else { + p_sys->p_tls = NULL; p_tls = NULL; if( i_port <= 0 ) i_port= 8080; @@ -382,7 +398,6 @@ void Close ( vlc_object_t *p_this ) { vlm_Delete( p_sys->p_vlm ); } - for( i = 0; i < p_sys->i_files; i++ ) { httpd_FileDelete( p_sys->pp_files[i]->p_file ); @@ -400,6 +415,13 @@ void Close ( vlc_object_t *p_this ) free( p_sys->pp_files ); } httpd_HostDelete( p_sys->p_httpd_host ); + /* TODO: do this in the httpd code to avoid code duplication */ + if( p_sys->p_tls != NULL ) + { + module_Unneed( p_sys->p_tls, p_sys->p_tls->p_module ); + vlc_object_detach( p_sys->p_tls ); + vlc_object_destroy( p_sys->p_tls ); + } free( p_sys ); }