1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2004 VideoLAN
5 * $Id: httpd.c 8263 2004-07-24 09:06:58Z courmisch $
7 * Authors: Remi Denis-Courmont <courmisch@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
32 * - client side stuff,
33 * - server-side client cert validation,
34 * - client-side server cert validation (?).
37 /*****************************************************************************
39 *****************************************************************************
40 * Allocates a whole server's TLS credentials.
41 * Returns NULL on error.
42 *****************************************************************************/
44 tls_ServerCreate( vlc_object_t *p_this, const char *psz_cert,
48 tls_server_t *p_server;
50 p_tls = vlc_object_create( p_this, VLC_OBJECT_TLS );
51 vlc_object_attach( p_tls, p_this );
53 p_tls->p_module = module_Need( p_tls, "tls", 0, 0 );
54 if( p_tls->p_module != NULL )
59 p_server = __tls_ServerCreate( p_tls, psz_cert, psz_key );
60 if( p_server != NULL )
62 msg_Dbg( p_this, "TLS/SSL provider initialized" );
66 msg_Err( p_this, "TLS/SSL provider error" );
67 module_Unneed( p_tls, p_tls->p_module );
70 msg_Err( p_this, "TLS/SSL provider not found" );
72 vlc_object_detach( p_tls );
73 vlc_object_destroy( p_tls );
78 /*****************************************************************************
80 *****************************************************************************
81 * Releases data allocated with tls_ServerCreate
82 *****************************************************************************/
84 tls_ServerDelete( tls_server_t *p_server )
86 tls_t *p_tls = p_server->p_tls;
88 __tls_ServerDelete( p_server );
90 module_Unneed( p_tls, p_tls->p_module );
91 vlc_object_detach( p_tls );
92 vlc_object_destroy( p_tls );
96 /*****************************************************************************
98 *****************************************************************************
99 * Allocates a client's TLS credentials.
100 * Returns NULL on error.
101 *****************************************************************************/
103 tls_ClientCreate( vlc_object_t *p_this, const char *psz_ca )
106 tls_session_t *p_session;
108 p_tls = vlc_object_create( p_this, VLC_OBJECT_TLS );
109 vlc_object_attach( p_tls, p_this );
111 p_tls->p_module = module_Need( p_tls, "tls", 0, 0 );
112 if( p_tls->p_module != NULL )
114 p_session = __tls_ClientCreate( p_tls, psz_ca );
115 if( p_session != NULL )
117 msg_Dbg( p_this, "TLS/SSL provider initialized" );
121 msg_Err( p_this, "TLS/SSL provider error" );
122 module_Unneed( p_tls, p_tls->p_module );
125 msg_Err( p_this, "TLS/SSL provider not found" );
127 vlc_object_detach( p_tls );
128 vlc_object_destroy( p_tls );
133 /*****************************************************************************
135 *****************************************************************************
136 * Releases data allocated with tls_ClientCreate
137 *****************************************************************************/
139 tls_ClientDelete( tls_session_t *p_session )
141 tls_t *p_tls = p_session->p_tls;
143 __tls_ClientDelete( p_session );
145 module_Unneed( p_tls, p_tls->p_module );
146 vlc_object_detach( p_tls );
147 vlc_object_destroy( p_tls );