Changeset 5aa8d01f4893a235c45968c54ab122941abcb8ec

Show
Ignore:
Timestamp:
06/11/04 17:26:40 (4 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1099758400 +0000
git-parent:

[ed4973755c4df225a7390edf03f7b980fda313f7]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1099758400 +0000
Message:

HTTP/SSL stream output

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/access_output/http.c

    r32f808e r5aa8d01  
    3131 
    3232#include "vlc_httpd.h" 
     33#include "vlc_tls.h" 
    3334 
    3435#define FREE( p ) if( p ) { free( p); (p) = NULL; } 
    3536 
    36 #define DEFAULT_PORT 8080 
     37#define DEFAULT_PORT        8080 
     38#define DEFAULT_SSL_PORT    8443 
    3739 
    3840/***************************************************************************** 
     
    5254#define MIME_TEXT N_("Mime") 
    5355#define MIME_LONGTEXT N_("Allows you to give the mime returned by the server." ) 
     56#define CERT_TEXT N_( "Certificate file" ) 
     57#define CERT_LONGTEXT N_( "HTTP/SSL stream output x509 PEM certificate file" ) 
     58#define KEY_TEXT N_( "Private key file" ) 
     59#define KEY_LONGTEXT N_( "HTTP/SSL stream output x509 PEM private key file" ) 
     60#define CA_TEXT N_( "Root CA file" ) 
     61#define CA_LONGTEXT N_( "HTTP/SSL stream output x509 PEM trusted root CA certificates file" ) 
     62#define CRL_TEXT N_( "CRL file" ) 
     63#define CRL_LONGTEXT N_( "HTTP/SSL stream output Certificates Revocation List file" ) 
    5464 
    5565vlc_module_begin(); 
     
    5767    set_capability( "sout access", 0 ); 
    5868    add_shortcut( "http" ); 
     69    add_shortcut( "https" ); 
    5970    add_shortcut( "mmsh" ); 
    6071    add_string( SOUT_CFG_PREFIX "user", "", NULL, USER_TEXT, USER_LONGTEXT, VLC_TRUE ); 
    6172    add_string( SOUT_CFG_PREFIX "pwd", "", NULL, PASS_TEXT, PASS_LONGTEXT, VLC_TRUE ); 
    6273    add_string( SOUT_CFG_PREFIX "mime", "", NULL, MIME_TEXT, MIME_LONGTEXT, VLC_TRUE ); 
     74    add_string( SOUT_CFG_PREFIX "cert", "vlc.pem", NULL, CERT_TEXT, CERT_LONGTEXT, VLC_TRUE ); 
     75    add_string( SOUT_CFG_PREFIX "key", NULL, NULL, KEY_TEXT, KEY_LONGTEXT, VLC_TRUE ); 
     76    add_string( SOUT_CFG_PREFIX "ca", NULL, NULL, CA_TEXT, CA_LONGTEXT, VLC_TRUE ); 
     77    add_string( SOUT_CFG_PREFIX "crl", NULL, NULL, CRL_TEXT, CRL_LONGTEXT, VLC_TRUE ); 
    6378    set_callbacks( Open, Close ); 
    6479vlc_module_end(); 
     
    97112    sout_access_out_t       *p_access = (sout_access_out_t*)p_this; 
    98113    sout_access_out_sys_t   *p_sys; 
     114    tls_server_t            *p_tls; 
    99115 
    100116    char                *psz_parser, *psz_name; 
     
    112128    { 
    113129        msg_Err( p_access, "Not enough memory" ); 
    114         return( VLC_EGENERIC )
     130        return VLC_ENOMEM
    115131    } 
    116132 
     
    146162    } 
    147163 
    148     if( i_bind_port <= 0 ) 
    149     { 
    150         i_bind_port = DEFAULT_PORT; 
    151     } 
    152  
    153164    if( !*psz_file_name ) 
    154165    { 
     
    168179    } 
    169180 
    170     p_sys->p_httpd_host = httpd_HostNew( VLC_OBJECT(p_access), psz_bind_addr, 
    171                                          i_bind_port ); 
     181    /* SSL support */ 
     182    if( p_access->psz_access && !strcmp( p_access->psz_access, "https" ) ) 
     183    { 
     184        const char *psz_cert, *psz_key; 
     185        psz_cert = config_GetPsz( p_this, SOUT_CFG_PREFIX"cert" ); 
     186        psz_key = config_GetPsz( p_this, SOUT_CFG_PREFIX"key" ); 
     187 
     188        p_tls = tls_ServerCreate( p_this, psz_cert, psz_key ); 
     189        if ( p_tls == NULL ) 
     190        { 
     191            msg_Err( p_this, "TLS initialization error" ); 
     192            free( psz_file_name ); 
     193            free( psz_name ); 
     194            free( p_sys ); 
     195            return VLC_EGENERIC; 
     196        } 
     197 
     198        psz_cert = config_GetPsz( p_this, SOUT_CFG_PREFIX"ca" ); 
     199        if ( ( psz_cert != NULL) && tls_ServerAddCA( p_tls, psz_cert ) ) 
     200        { 
     201            msg_Err( p_this, "TLS CA error" ); 
     202            tls_ServerDelete( p_tls ); 
     203            free( psz_file_name ); 
     204            free( psz_name ); 
     205            free( p_sys ); 
     206            return VLC_EGENERIC; 
     207        } 
     208 
     209        psz_cert = config_GetPsz( p_this, SOUT_CFG_PREFIX"crl" ); 
     210        if ( ( psz_cert != NULL) && tls_ServerAddCRL( p_tls, psz_cert ) ) 
     211        { 
     212            msg_Err( p_this, "TLS CRL error" ); 
     213            tls_ServerDelete( p_tls ); 
     214            free( psz_file_name ); 
     215            free( psz_name ); 
     216            free( p_sys ); 
     217            return VLC_EGENERIC; 
     218        } 
     219 
     220        if( i_bind_port <= 0 ) 
     221            i_bind_port = DEFAULT_SSL_PORT; 
     222    } 
     223    else 
     224    { 
     225        p_tls = NULL; 
     226        if( i_bind_port <= 0 ) 
     227            i_bind_port = DEFAULT_PORT; 
     228    } 
     229 
     230    p_sys->p_httpd_host = httpd_TLSHostNew( VLC_OBJECT(p_access), 
     231                                            psz_bind_addr, i_bind_port, 
     232                                            p_tls ); 
    172233    if( p_sys->p_httpd_host == NULL ) 
    173234    { 
     
    175236                 psz_bind_addr, i_bind_port ); 
    176237 
     238        if( p_tls != NULL ) 
     239            tls_ServerDelete( p_tls ); 
    177240        free( psz_name ); 
    178241        free( psz_file_name );