tls_session_sys_t *p_sys;
struct virtual_socket_t sock;
- int (*pf_handshake) ( tls_session_t *, int, const char * );
+ int (*pf_handshake) ( tls_session_t *, int );
int (*pf_handshake2) ( tls_session_t * );
void (*pf_close) ( tls_session_t * );
};
# define tls_ServerSessionPrepare( a ) (((tls_server_t *)a)->pf_session_prepare (a))
-# define tls_ServerSessionHandshake( a, b ) (((tls_session_t *)a)->pf_handshake (a, b, NULL))
+# define tls_ServerSessionHandshake( a, b ) (((tls_session_t *)a)->pf_handshake (a, b))
# define tls_ServerSessionClose( a ) (((tls_session_t *)a)->pf_close (a))
VLC_EXPORT( tls_session_t *, tls_ClientCreate, ( vlc_object_t *, int, const char * ) );
VLC_EXPORT( void, tls_ClientDelete, ( tls_session_t * ) );
-# define tls_ClientSessionHandshake( a, b, c ) (((tls_session_t *)a)->pf_handshake (a, b, c))
+# define tls_ClientSessionHandshake( a, b ) (((tls_session_t *)a)->pf_handshake (a, b))
# define tls_SessionContinueHandshake( a ) (((tls_session_t *)a)->pf_handshake2 (a))
* needed, 2 if more would-be blocking send is required.
*/
static int
-gnutls_ContinueHandshake( tls_session_t *p_session)
+gnutls_ContinueHandshake (tls_session_t *p_session)
{
- tls_session_sys_t *p_sys;
+ tls_session_sys_t *p_sys = p_session->p_sys;
int val;
- p_sys = (tls_session_sys_t *)(p_session->p_sys);
-
#ifdef WIN32
WSASetLastError( 0 );
#endif
* Starts negociation of a TLS session.
*
* @param fd stream socket already connected with the peer.
- * @param psz_hostname if not NULL, hostname to mention as a Server Name,
- * and to be found in the server's certificate.
*
* @return -1 on error (you need not and must not call tls_SessionClose),
* 0 on succesful handshake completion, 1 if more would-be blocking recv is
* needed, 2 if more would-be blocking send is required.
*/
static int
-gnutls_BeginHandshake( tls_session_t *p_session, int fd,
- const char *psz_hostname )
+gnutls_BeginHandshake( tls_session_t *p_session, int fd )
{
tls_session_sys_t *p_sys = p_session->p_sys;
gnutls_transport_set_ptr (p_sys->session, (gnutls_transport_ptr)(intptr_t)fd);
- if( psz_hostname != NULL )
- {
- gnutls_server_name_set (p_sys->session, GNUTLS_NAME_DNS, psz_hostname,
- strlen (psz_hostname));
- p_sys->psz_hostname = strdup (psz_hostname);
- if (p_sys->psz_hostname == NULL)
- {
- p_session->pf_close (p_session);
- return -1;
- }
- }
-
return p_session->pf_handshake2( p_session );
}
gnutls_Addx509Directory (VLC_OBJECT (p_session), p_sys->x509_cred,
path, VLC_TRUE);
- i_val = gnutls_init( &p_sys->session.session, GNUTLS_CLIENT );
+ i_val = gnutls_init (&p_sys->session.session, GNUTLS_CLIENT);
if (i_val != 0)
{
msg_Err (obj, "cannot initialize TLS session: %s",
goto s_error;
}
+ char *servername = var_GetNonEmptyString (p_session, "tls-server-name");
+ if (servername != NULL )
+ {
+ p_sys->session.psz_hostname = servername;
+ gnutls_server_name_set (p_sys->session.session, GNUTLS_NAME_DNS,
+ servername, strlen (servername));
+ }
+
return VLC_SUCCESS;
s_error:
if (cl == NULL)
return NULL;
+ var_Create (cl, "tls-server-name", VLC_VAR_STRING);
+ if (psz_hostname != NULL)
+ {
+ msg_Dbg (cl, "requested server name: %s", psz_hostname);
+ var_SetString (cl, "tls-server-name", psz_hostname);
+ }
+ else
+ msg_Dbg (cl, "requested anonymous server");
+
cl->p_module = module_Need (cl, "tls client", 0, 0);
if (cl->p_module == NULL)
{
return NULL;
}
- int val = tls_ClientSessionHandshake (cl, fd, psz_hostname);
+ int val = tls_ClientSessionHandshake (cl, fd);
while (val > 0)
val = tls_SessionContinueHandshake (cl);