From: Jack Lau via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Jack Lau <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] avformat/tls_openssl: two small cleanup (PR #21697)
Date: Mon, 09 Feb 2026 09:37:12 -0000
Message-ID: <177062983329.25.3597347337825758923@4457048688e7> (raw)
PR #21697 opened by Jack Lau (JackLau)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21697
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21697.patch
>From db6e39b3a380b2635859bfca7864548c5626fb72 Mon Sep 17 00:00:00 2001
From: Jack Lau <jacklau1222gm@gmail.com>
Date: Mon, 9 Feb 2026 15:12:23 +0800
Subject: [PATCH 1/2] avformat/tls_openssl: use EINVAL when X509_digest failed
This function just calculate and copy the fingerprint
to the provided buf, will not allocate memory.
It fails when the input (such as cert) is invalid.
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
---
libavformat/tls_openssl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index c7d6ff6cf4..821f9ffd04 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -100,7 +100,7 @@ static int x509_fingerprint(X509 *cert, char **fingerprint)
if (X509_digest(cert, EVP_sha256(), md, &n) != 1) {
av_log(NULL, AV_LOG_ERROR, "TLS: Failed to generate fingerprint, %s\n",
ERR_error_string(ERR_get_error(), NULL));
- return AVERROR(ENOMEM);
+ return AVERROR(EINVAL);
}
av_bprint_init(&buf, n*3, n*3);
--
2.52.0
>From 8dd94aa113c01a5c88c0205a6756638311b2ac9d Mon Sep 17 00:00:00 2001
From: Jack Lau <jacklau1222gm@gmail.com>
Date: Mon, 9 Feb 2026 17:27:03 +0800
Subject: [PATCH 2/2] avformat/tls_openssl: update the outdated comments
Loading CA certificate is supported.
Remove unrelated comments.
The underlying socket can be tcp or udp.
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
---
libavformat/tls_openssl.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c
index 821f9ffd04..0ae0980cc3 100644
--- a/libavformat/tls_openssl.c
+++ b/libavformat/tls_openssl.c
@@ -267,7 +267,6 @@ static int openssl_gen_certificate(EVP_PKEY *pkey, X509 **cert, char **fingerpri
goto enomem_end;
}
- // TODO: Support non-self-signed certificate, for example, load from a file.
subject = X509_NAME_new();
if (!subject) {
goto enomem_end;
@@ -812,17 +811,7 @@ static int dtls_start(URLContext *h, const char *url, int flags, AVDictionary **
else
SSL_set_connect_state(c->ssl);
- /**
- * During initialization, we only need to call SSL_do_handshake once because SSL_read consumes
- * the handshake message if the handshake is incomplete.
- * To simplify maintenance, we initiate the handshake for both the DTLS server and client after
- * sending out the ICE response in the start_active_handshake function. It's worth noting that
- * although the DTLS server may receive the ClientHello immediately after sending out the ICE
- * response, this shouldn't be an issue as the handshake function is called before any DTLS
- * packets are received.
- *
- * The SSL_do_handshake can't be called if DTLS hasn't prepare for udp.
- */
+ /* The SSL_do_handshake can't be called if DTLS hasn't prepare for udp. */
if (!c->tls_shared.external_sock) {
ret = dtls_handshake(h);
// Fatal SSL error, for example, no available suite when peer is DTLS 1.0 while we are DTLS 1.2.
@@ -933,7 +922,7 @@ static int tls_write(URLContext *h, const uint8_t *buf, int size)
URLContext *uc = s->is_dtls ? s->udp : s->tcp;
int ret;
- // Set or clear the AVIO_FLAG_NONBLOCK on c->tls_shared.tcp
+ // Set or clear the AVIO_FLAG_NONBLOCK on the underlying socket
uc->flags &= ~AVIO_FLAG_NONBLOCK;
uc->flags |= h->flags & AVIO_FLAG_NONBLOCK;
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2026-02-09 9:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=177062983329.25.3597347337825758923@4457048688e7 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git