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
32c3a603
Commit
32c3a603
authored
Jan 13, 2016
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tls: split server-specific session creation function...
...from common code. And document.
parent
6f79b0b0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
18 deletions
+42
-18
include/vlc_tls.h
include/vlc_tls.h
+21
-3
src/libvlccore.sym
src/libvlccore.sym
+1
-1
src/network/httpd.c
src/network/httpd.c
+1
-1
src/network/tls.c
src/network/tls.c
+18
-12
test/modules/misc/tls.c
test/modules/misc/tls.c
+1
-1
No files found.
include/vlc_tls.h
View file @
32c3a603
...
...
@@ -73,9 +73,27 @@ VLC_API vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *, int fd,
const
char
*
host
,
const
char
*
service
,
const
char
*
const
*
alpn
,
char
**
alp
);
VLC_API
vlc_tls_t
*
vlc_tls_SessionCreate
(
vlc_tls_creds_t
*
,
int
fd
,
const
char
*
host
,
const
char
*
const
*
alpn
);
/**
* Creates a TLS server session.
*
* Allocates a Transport Layer Security (TLS) session as the server side, using
* cryptographic keys pair and X.509 certificates chain already loaded with
* vlc_tls_ServerCreate().
*
* Unlike vlc_tls_ClientSessionCreate(), this function does not perform any
* actual network I/O. vlc_tls_SessionHandshake() must be used to perform the
* TLS handshake before sending and receiving data through the TLS session.
*
* This function is non-blocking and is not a cancellation point.
*
* @param creds server credentials, i.e. keys pair and X.509 certificates chain
* @param alpn NULL-terminated list of Application Layer Protocols
* to negotiate, or NULL to not negotiate protocols
*
* @return TLS session, or NULL on error.
*/
VLC_API
vlc_tls_t
*
vlc_tls_ServerSessionCreate
(
vlc_tls_creds_t
*
creds
,
int
fd
,
const
char
*
const
*
alpn
);
/**
* Destroys a TLS session down.
...
...
src/libvlccore.sym
View file @
32c3a603
...
...
@@ -431,7 +431,7 @@ vlc_tls_ClientCreate
vlc_tls_ServerCreate
vlc_tls_Delete
vlc_tls_ClientSessionCreate
vlc_tls_SessionCreate
vlc_tls_Se
rverSe
ssionCreate
vlc_tls_SessionDelete
vlc_tls_Read
vlc_tls_Write
...
...
src/network/httpd.c
View file @
32c3a603
...
...
@@ -2042,7 +2042,7 @@ static void httpdLoop(httpd_host_t *host)
{
const
char
*
alpn
[]
=
{
"http/1.1"
,
NULL
};
p_tls
=
vlc_tls_Se
ssionCreate
(
host
->
p_tls
,
fd
,
NULL
,
alpn
);
p_tls
=
vlc_tls_Se
rverSessionCreate
(
host
->
p_tls
,
fd
,
alpn
);
}
else
p_tls
=
NULL
;
...
...
src/network/tls.c
View file @
32c3a603
...
...
@@ -128,8 +128,9 @@ void vlc_tls_Delete (vlc_tls_creds_t *crd)
/*** TLS session ***/
vlc_tls_t
*
vlc_tls_SessionCreate
(
vlc_tls_creds_t
*
crd
,
int
fd
,
const
char
*
host
,
const
char
*
const
*
alpn
)
static
vlc_tls_t
*
vlc_tls_SessionCreate
(
vlc_tls_creds_t
*
crd
,
int
fd
,
const
char
*
host
,
const
char
*
const
*
alpn
)
{
vlc_tls_t
*
sock
=
vlc_tls_SocketOpen
(
VLC_OBJECT
(
crd
),
fd
);
if
(
unlikely
(
sock
==
NULL
))
...
...
@@ -145,12 +146,15 @@ vlc_tls_t *vlc_tls_SessionCreate (vlc_tls_creds_t *crd, int fd,
session
->
obj
=
crd
->
p_parent
;
session
->
p
=
sock
;
int
val
=
crd
->
open
(
crd
,
session
,
sock
,
host
,
alpn
);
if
(
val
!=
VLC_SUCCESS
)
int
canc
=
vlc_savecancel
();
if
(
crd
->
open
(
crd
,
session
,
sock
,
host
,
alpn
)
!=
VLC_SUCCESS
)
{
free
(
session
);
session
=
NULL
;
session
=
NULL
;
}
vlc_restorecancel
(
canc
);
return
session
;
}
...
...
@@ -180,17 +184,13 @@ vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *crd, int fd,
const
char
*
host
,
const
char
*
service
,
const
char
*
const
*
alpn
,
char
**
alp
)
{
vlc_tls_t
*
session
;
int
canc
,
val
;
int
val
;
canc
=
vlc_savecancel
();
session
=
vlc_tls_SessionCreate
(
crd
,
fd
,
host
,
alpn
);
vlc_tls_t
*
session
=
vlc_tls_SessionCreate
(
crd
,
fd
,
host
,
alpn
);
if
(
session
==
NULL
)
{
vlc_restorecancel
(
canc
);
return
NULL
;
}
int
canc
=
vlc_savecancel
();
mtime_t
deadline
=
mdate
();
deadline
+=
var_InheritInteger
(
crd
,
"ipv4-timeout"
)
*
1000
;
...
...
@@ -230,6 +230,12 @@ error:
return
session
;
}
vlc_tls_t
*
vlc_tls_ServerSessionCreate
(
vlc_tls_creds_t
*
crd
,
int
fd
,
const
char
*
const
*
alpn
)
{
return
vlc_tls_SessionCreate
(
crd
,
fd
,
NULL
,
alpn
);
}
ssize_t
vlc_tls_Read
(
vlc_tls_t
*
session
,
void
*
buf
,
size_t
len
,
bool
waitall
)
{
struct
pollfd
ufd
;
...
...
test/modules/misc/tls.c
View file @
32c3a603
...
...
@@ -113,7 +113,7 @@ static int securepair(vlc_thread_t *th, vlc_tls_t **restrict client,
val
=
tlspair
(
insecurev
);
assert
(
val
==
0
);
server
=
vlc_tls_Se
ssionCreate
(
server_creds
,
insecurev
[
0
],
NULL
,
alpnv
[
0
]);
server
=
vlc_tls_Se
rverSessionCreate
(
server_creds
,
insecurev
[
0
]
,
alpnv
[
0
]);
assert
(
server
!=
NULL
);
val
=
vlc_clone
(
th
,
tls_echo
,
server
,
VLC_THREAD_PRIORITY_LOW
);
...
...
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