1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00
Commit Graph

85 Commits

Author SHA1 Message Date
Marton Balint
f1d5114103 avformat/tls_openssl: do not cleanup tls after a successful dtls_start()
Regression since 8e11e2cdb8.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-02 18:41:47 +02:00
Marton Balint
8e11e2cdb8 avformat/tls_openssl: initialize underlying protocol early for dtls_start()
The same way we do with TLS, so all tls URL options will be properly supported.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Andreas Rheinhardt
b815431126 Revert "avformat/tls_openssl: add av_assert0() for tls_shared"
This reverts commits fd55c4b5f7
(for tls_openssl.c) and c74181a04b
(for tls_gnutls.c).

It is impossible for a pointer to a member of a structure
to be NULL: If the containing structure exists, the member
exists and can't have a NULL address; if the containing
structure does not exist, then getting a pointer to the
substructure via &c->tls_shared would already be undefined
behavior.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-22 22:02:03 +02:00
Andreas Rheinhardt
db6cd6c6bf avformat/tls_openssl: Don't call functions inside FFMIN
It may call the function multiple times.

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-22 21:58:00 +02:00
Marton Balint
f2be0e68ef avformat/tls: move AVClass to TLSShared
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Jack Lau
37507c6a78 avformat/whip: remove DTLSState enum
This patch aims to simplify the dtls handshake process
since dtls handshake use force block mode

We can just use the return code instead of DTLSState enum

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-16 06:25:04 +00:00
Kacper Michajłow
61d0050924 avformat/tls_openssl: simplify fingerprint generation
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-16 00:15:30 +00:00
Kacper Michajłow
4676f97928 avformat/tls_openssl: clean keys serialization
It was unnecessary convoluted, remove not needed memory allocations,
snprintf.

Also fixes posibility to call snprinft with NULL as %s input.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-16 00:15:30 +00:00
Kacper Michajłow
3a8b3dfeca avformat/tls_openssl: use ascii - (0x2D) instead of 0x2010 hyphen
Too much AI is bad for you...

Fixes: 167e343bbe
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-16 00:15:30 +00:00
winlin
a72cc49e8a avformat/tls_openssl: fix X509 cert serial number might be negative
See RFC5280 4.1.2.2

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-10 02:26:16 +00:00
Jack Lau
dc9f676b99 avformat/tls: add new option use_srtp to control whether enable it
The SRTP profile string "SRTP_AES128_CM_SHA1_80" is only used when
use_srtp is enabled. Move its declaration inside the "if (s->use_srtp)"
block to limit scope

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Jack Lau
fd55c4b5f7 avformat/tls_openssl: add av_assert0() for tls_shared
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Jack Lau
d7bc024476 avformat/tls_openssl: simplify the external_sock check
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Jack Lau
553fa9e3df avformat/tls_openssl: cleanup the pointer name of TLSContext and TLSShared
Pure cleanup, no functional changes
Unify local pointer names to `TLSContext *c` and `TLSShared *s` to
reduce confusion from inconsistent names (e.g. p, ctx, s, c)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Timo Rothenpieler
262d41c804 all: fix typos found by codespell 2025-08-03 13:48:47 +02:00
Kacper Michajłow
daee46ed7e Revert "avformat/tls_openssl: properly get new BIO index"
BIO_get_new_index() is static counter meant to get index for custom bio
type definition. As we can read in the documentation:

> Note that BIO_get_new_index() can only be used 127 times before it
> returns an error.

We cannot call it repeatedly, because it will fail eventually.

To my understanding the index is not needed in our use and we could
safely use BIO_TYPE_NONE. Documentation states:

> type can be set to either BIO_TYPE_NONE or via BIO_get_new_index() if
> a unique type is required for searching (See BIO_find_type(3))

We don't use any search related functions.

This reverts commit 816dad231f.
Fixes: https://github.com/mpv-player/mpv/issues/16589

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-30 02:56:12 +02:00
Marvin Scholz
080dc4cf54 avformat/tls_openssl: load default verify locations
When no explicit CAs file is set, load the default locations,
else there is no way for verification to succeed.

This matches the behavior of other TLS backends.
2025-07-22 02:43:54 +02:00
Marvin Scholz
f4befeb767 avformat/tls_openssl: verify setting hostname for SNI 2025-07-22 02:43:54 +02:00
Daniel N Pettersson
e56fd2af1a avformat/tls_openssl: add hostname for verification
When verification is enabled (using -tls_verify 1) now
the hostname will be verified properly too, while before
only other aspects of the certificate were checked.

Co-Authored-By: Marvin Scholz <epirat07@gmail.com>
2025-07-22 02:43:54 +02:00
Timo Rothenpieler
e6d2c67cd0 avformat/tls_openssl: avoid unusual inline-if style 2025-07-17 14:06:07 +02:00
Jack Lau
abb274b154 avformat/tls_openssl: make tls and dtls use one close function
Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 14:04:32 +02:00
Jack Lau
e6af82c498 avformat/tls_openssl: remove all redundant "TLS: " in log with AVClass
Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 02:35:11 +02:00
Jack Lau
dda91b87e8 avformat/tls_openssl: replace 1 with TLS_ST_OK to be more clear
Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 02:35:07 +02:00
Timo Rothenpieler
95eae5dd50 avformat/tls_openssl: unset nonblock flag on correct URLContext during dtls handshake
The internal BIO functions do not in fact look at this flag, only the outer
tls_read and tls_write functions do.
2025-07-17 02:20:34 +02:00
Jack Lau
7afe1167e5 avformat/tls_openssl: set tlsext host name after init ssl
Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 02:04:38 +02:00
Timo Rothenpieler
483e509169 avformat/tls_openssl: automatically generate self-signed certificate when none is provided in listen mode 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
454f161b4b avformat/tls_openssl: make generating fingerprints optional 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
40ce64eae7 avformat/tls_openssl: don't expose deprecated EC_KEY outside of its function 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
5339db2cf4 avformat/tls_openssl: properly free generated/read keys and certificates 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
49badc8689 avformat/tls_openssl: don't enable read_ahead in dtls mode
OpenSSL docs say:
These functions have no impact when used with DTLS.
2025-07-16 18:46:55 +02:00
Timo Rothenpieler
31abcc1505 avformar/tls_openssl: use correct info callback in DTLS mode 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
5edbfc4bae avformat/tls_openssl: clean up peer verify logic in dtls mode 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
95fd0840fe avformat/tls_openssl: don't hardcode ciphers and curves for dtls 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
f3355a1fff avformat/tls_openssl: properly limit written size to data mtu 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
576f44016a avformat/tls_openssl: set default MTU if none is set 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
b6e808d28b avformat/tls_openssl: initialize DTLS context with correct method 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
db0adbbd3f avformat/tls_openssl: don't abort if dtls has no key/cert set 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
951013e603 avformat/tls_openssl: force dtls handshake to be blocking
There is no sensible way to handle this otherwise anyway, one just has
to loop over this function until it succeeds.
2025-07-16 18:46:55 +02:00
Timo Rothenpieler
87b09f3931 avformat/tls_openssl: set dtls remote addr in listen mode
Taken from the first received packet, which will signify the now
permanent peer of this DTLS "connection".
2025-07-16 18:46:55 +02:00
Timo Rothenpieler
6af099522e avformat/tls: make passing an external socket universal 2025-07-11 17:49:57 +02:00
Timo Rothenpieler
2c7e117fe0 avformat/tls: move whip specific init out of generic tls code 2025-07-11 17:49:57 +02:00
Marvin Scholz
019ca5f013 avformat/tls_openssl: use SSL_CTX_set_min_proto_version
Using SSL_CTX_set_options to disallow specific versions is
discouraged by the documentation, which recommends to use
SSL_CTX_set_min_proto_version instead.
2025-07-07 01:52:47 +02:00
Marvin Scholz
fb38d8759b avformat/tls_openssl: use TLS_[client|server]_method
SSLv23_*_method was just a define for these anyway since OpenSSL 1.1.0
and the old functions are deprecated.
2025-07-07 01:52:47 +02:00
Marvin Scholz
aaffa9bc72 avformat/tls_openssl: remove unnecessary checks
Calling av_free with NULL is a no-op so this check is not needed.
2025-07-07 01:52:46 +02:00
Marvin Scholz
3abc8d507b avformat/tls_openssl: remove leftover comment 2025-07-07 01:52:46 +02:00
Marvin Scholz
816dad231f avformat/tls_openssl: properly get new BIO index
As noted in the OpenSSL documentation, BIO_get_new_index must be
used to get a new BIO index. This is ORd with the proper type flag
BIO_TYPE_SOURCE_SINK.
2025-07-07 01:52:46 +02:00
Marvin Scholz
1702becd64 avformat/tls_openssl: remove now unnecessary define
This was used previously when multiple OpenSSL versions were supported
that required this to be handled differently.
2025-07-07 01:52:46 +02:00
Marvin Scholz
f0913b3f16 avformat: tls: drop support for OpenSSL < 1.1.0 2025-07-07 01:52:46 +02:00
Timo Rothenpieler
4a4a566d6e avformat/tls: remove unused fingerprint option 2025-07-03 22:18:10 +02:00
Timo Rothenpieler
043d3fef8a avformat/tls_openssl: use existing context handle 2025-07-03 22:18:10 +02:00