Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
2200a457
Commit
2200a457
authored
Aug 23, 2014
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gnutls: move handshake callback to credentials (alongside open/close)
parent
ef70096b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
23 deletions
+22
-23
include/vlc_tls.h
include/vlc_tls.h
+2
-2
modules/misc/gnutls.c
modules/misc/gnutls.c
+12
-15
src/network/tls.c
src/network/tls.c
+8
-6
No files found.
include/vlc_tls.h
View file @
2200a457
...
...
@@ -42,7 +42,6 @@ struct vlc_tls
vlc_tls_sys_t
*
sys
;
struct
virtual_socket_t
sock
;
int
(
*
handshake
)
(
vlc_tls_t
*
,
const
char
*
host
,
const
char
*
service
);
};
VLC_API
vlc_tls_t
*
vlc_tls_ClientSessionCreate
(
vlc_tls_creds_t
*
,
int
fd
,
...
...
@@ -66,7 +65,8 @@ struct vlc_tls_creds
vlc_tls_creds_sys_t
*
sys
;
int
(
*
open
)
(
vlc_tls_creds_t
*
,
vlc_tls_t
*
,
int
fd
,
const
char
*
host
);
void
(
*
close
)
(
vlc_tls_creds_t
*
,
vlc_tls_t
*
);
int
(
*
handshake
)
(
vlc_tls_t
*
,
const
char
*
host
,
const
char
*
service
);
void
(
*
close
)
(
vlc_tls_t
*
);
};
VLC_API
vlc_tls_creds_t
*
vlc_tls_ClientCreate
(
vlc_object_t
*
);
...
...
modules/misc/gnutls.c
View file @
2200a457
...
...
@@ -423,7 +423,7 @@ struct vlc_tls_creds_sys
* Terminates TLS session and releases session data.
* You still have to close the socket yourself.
*/
static
void
gnutls_SessionClose
(
vlc_tls_
creds_t
*
crd
,
vlc_tls_
t
*
session
)
static
void
gnutls_SessionClose
(
vlc_tls_t
*
session
)
{
vlc_tls_sys_t
*
sys
=
session
->
sys
;
...
...
@@ -432,7 +432,6 @@ static void gnutls_SessionClose (vlc_tls_creds_t *crd, vlc_tls_t *session)
gnutls_deinit
(
sys
->
session
);
free
(
sys
);
(
void
)
crd
;
}
...
...
@@ -447,10 +446,6 @@ static int gnutls_SessionOpen (vlc_tls_creds_t *crd, vlc_tls_t *session,
session
->
sock
.
p_sys
=
session
;
session
->
sock
.
pf_send
=
gnutls_Send
;
session
->
sock
.
pf_recv
=
gnutls_Recv
;
if
(
type
==
GNUTLS_SERVER
)
session
->
handshake
=
gnutls_ContinueHandshake
;
else
session
->
handshake
=
gnutls_HandshakeAndValidate
;
sys
->
handshaked
=
false
;
int
val
=
gnutls_init
(
&
sys
->
session
,
type
);
...
...
@@ -479,7 +474,7 @@ static int gnutls_SessionOpen (vlc_tls_creds_t *crd, vlc_tls_t *session,
return
VLC_SUCCESS
;
error:
gnutls_SessionClose
(
crd
,
session
);
gnutls_SessionClose
(
session
);
return
VLC_EGENERIC
;
}
...
...
@@ -528,10 +523,6 @@ static int OpenServer (vlc_tls_creds_t *crd, const char *cert, const char *key)
if
(
unlikely
(
sys
==
NULL
))
goto
error
;
crd
->
sys
=
sys
;
crd
->
open
=
gnutls_ServerSessionOpen
;
crd
->
close
=
gnutls_SessionClose
;
/* Sets server's credentials */
val
=
gnutls_certificate_allocate_credentials
(
&
sys
->
x509_cred
);
if
(
val
!=
0
)
...
...
@@ -600,6 +591,11 @@ static int OpenServer (vlc_tls_creds_t *crd, const char *cert, const char *key)
gnutls_strerror
(
val
));
}
crd
->
sys
=
sys
;
crd
->
open
=
gnutls_ServerSessionOpen
;
crd
->
handshake
=
gnutls_ContinueHandshake
;
crd
->
close
=
gnutls_SessionClose
;
return
VLC_SUCCESS
;
error:
...
...
@@ -635,10 +631,6 @@ static int OpenClient (vlc_tls_creds_t *crd)
if
(
unlikely
(
sys
==
NULL
))
goto
error
;
crd
->
sys
=
sys
;
crd
->
open
=
gnutls_ClientSessionOpen
;
crd
->
close
=
gnutls_SessionClose
;
int
val
=
gnutls_certificate_allocate_credentials
(
&
sys
->
x509_cred
);
if
(
val
!=
0
)
{
...
...
@@ -657,6 +649,11 @@ static int OpenClient (vlc_tls_creds_t *crd)
gnutls_certificate_set_verify_flags
(
sys
->
x509_cred
,
GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT
);
crd
->
sys
=
sys
;
crd
->
open
=
gnutls_ClientSessionOpen
;
crd
->
handshake
=
gnutls_HandshakeAndValidate
;
crd
->
close
=
gnutls_SessionClose
;
return
VLC_SUCCESS
;
error:
free
(
sys
);
...
...
src/network/tls.c
View file @
2200a457
...
...
@@ -157,18 +157,20 @@ vlc_tls_t *vlc_tls_SessionCreate (vlc_tls_creds_t *crd, int fd,
return
NULL
;
}
void
vlc_tls_SessionDelete
(
vlc_tls_t
*
session
)
int
vlc_tls_SessionHandshake
(
vlc_tls_t
*
session
,
const
char
*
host
,
const
char
*
service
)
{
vlc_tls_creds_t
*
crd
=
(
vlc_tls_creds_t
*
)(
session
->
p_parent
);
crd
->
close
(
crd
,
session
);
vlc_object_release
(
session
);
return
crd
->
handshake
(
session
,
host
,
service
);
}
int
vlc_tls_SessionHandshake
(
vlc_tls_t
*
session
,
const
char
*
host
,
const
char
*
service
)
void
vlc_tls_SessionDelete
(
vlc_tls_t
*
session
)
{
return
session
->
handshake
(
session
,
host
,
service
);
vlc_tls_creds_t
*
crd
=
(
vlc_tls_creds_t
*
)(
session
->
p_parent
);
crd
->
close
(
session
);
vlc_object_release
(
session
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment