VLC_API vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *, int fd,
const char *host);
vlc_tls_t *vlc_tls_ServerSessionCreate (vlc_tls_creds_t *, int fd);
-int vlc_tls_ServerSessionHandshake (vlc_tls_t *);
+int vlc_tls_SessionHandshake (vlc_tls_t *);
VLC_API void vlc_tls_SessionDelete (vlc_tls_t *);
-#define vlc_tls_ServerSessionDelete vlc_tls_SessionDelete
/* NOTE: It is assumed that a->sock.p_sys = a */
# define tls_Send( a, b, c ) (((vlc_tls_t *)a)->sock.pf_send (a, b, c))
vlc_tls_creds_t *vlc_tls_ServerCreate (vlc_object_t *,
const char *cert, const char *key);
VLC_API void vlc_tls_Delete (vlc_tls_creds_t *);
-#define vlc_tls_ServerDelete vlc_tls_Delete
int vlc_tls_ServerAddCA (vlc_tls_creds_t *srv, const char *path);
int vlc_tls_ServerAddCRL (vlc_tls_creds_t *srv, const char *path);
return httpd_HostCreate( obj, "http-host", "https-port", tls );
error:
- vlc_tls_ServerDelete( tls );
+ vlc_tls_Delete( tls );
return NULL;
}
vlc_mutex_unlock( &httpd.mutex );
vlc_UrlClean( &url );
- if( p_tls != NULL )
- vlc_tls_ServerDelete( p_tls );
+ vlc_tls_Delete( p_tls );
return host;
}
}
vlc_UrlClean( &url );
-
- if( p_tls != NULL )
- vlc_tls_ServerDelete( p_tls );
-
+ vlc_tls_Delete( p_tls );
return NULL;
}
/* TODO */
}
- if( host->p_tls != NULL)
- vlc_tls_ServerDelete( host->p_tls );
-
+ vlc_tls_Delete( host->p_tls );
net_ListenClose( host->fds );
vlc_cond_destroy( &host->wait );
vlc_mutex_destroy( &host->lock );
if( cl->fd >= 0 )
{
if( cl->p_tls != NULL )
- vlc_tls_ServerSessionDelete( cl->p_tls );
+ vlc_tls_SessionDelete( cl->p_tls );
net_Close( cl->fd );
cl->fd = -1;
}
cl->p_tls = p_tls;
httpd_ClientInit( cl, now );
+ if( p_tls != NULL )
+ cl->i_state = HTTPD_CLIENT_TLS_HS_OUT;
return cl;
}
}
}
-static void httpd_ClientTlsHsIn( httpd_client_t *cl )
+static void httpd_ClientTlsHandshake( httpd_client_t *cl )
{
- switch( vlc_tls_ServerSessionHandshake( cl->p_tls ) )
+ switch( vlc_tls_SessionHandshake( cl->p_tls ) )
{
case 0:
cl->i_state = HTTPD_CLIENT_RECEIVING;
case -1:
cl->i_state = HTTPD_CLIENT_DEAD;
- cl->p_tls = NULL;
- break;
-
- case 2:
- cl->i_state = HTTPD_CLIENT_TLS_HS_OUT;
- }
-}
-
-static void httpd_ClientTlsHsOut( httpd_client_t *cl )
-{
- switch( vlc_tls_ServerSessionHandshake( cl->p_tls ) )
- {
- case 0:
- cl->i_state = HTTPD_CLIENT_RECEIVING;
- break;
-
- case -1:
- cl->i_state = HTTPD_CLIENT_DEAD;
- cl->p_tls = NULL;
break;
case 1:
cl->i_state = HTTPD_CLIENT_TLS_HS_IN;
break;
+
+ case 2:
+ cl->i_state = HTTPD_CLIENT_TLS_HS_OUT;
+ break;
}
}
{
httpd_ClientSend( cl );
}
- else if( cl->i_state == HTTPD_CLIENT_TLS_HS_IN )
+ else if( cl->i_state == HTTPD_CLIENT_TLS_HS_IN
+ || cl->i_state == HTTPD_CLIENT_TLS_HS_OUT )
{
- httpd_ClientTlsHsIn( cl );
- }
- else if( cl->i_state == HTTPD_CLIENT_TLS_HS_OUT )
- {
- httpd_ClientTlsHsOut( cl );
+ httpd_ClientTlsHandshake( cl );
}
}
for( nfd = 0; nfd < host->nfd; nfd++ )
{
httpd_client_t *cl;
- int i_state = -1;
int fd = ufd[nfd].fd;
assert (fd == host->fds[nfd]);
vlc_tls_t *p_tls;
if( host->p_tls != NULL )
- {
p_tls = vlc_tls_ServerSessionCreate( host->p_tls, fd );
- switch( vlc_tls_ServerSessionHandshake( p_tls ) )
- {
- case -1:
- msg_Err( host, "Rejecting TLS connection" );
- /* p_tls is destroyed implicitly */
- net_Close( fd );
- fd = -1;
- p_tls = NULL;
- continue;
-
- case 1: /* missing input - most likely */
- i_state = HTTPD_CLIENT_TLS_HS_IN;
- break;
-
- case 2: /* missing output */
- i_state = HTTPD_CLIENT_TLS_HS_OUT;
- break;
- }
- }
else
p_tls = NULL;
cl = httpd_ClientNew( fd, p_tls, now );
+
TAB_APPEND( host->i_client, host->client, cl );
- if( i_state != -1 )
- cl->i_state = i_state; // override state for TLS
}
}
vlc_mutex_unlock( &host->lock );