Skip to content

options: enable tls-verify by default #17909

Open
kasper93 wants to merge 16 commits into
mpv-player:masterfrom
kasper93:tls-verify
Open

options: enable tls-verify by default #17909
kasper93 wants to merge 16 commits into
mpv-player:masterfrom
kasper93:tls-verify

Conversation

@kasper93
Copy link
Copy Markdown
Member

No description provided.

kasper93 and others added 14 commits May 11, 2026 22:40
stream-lavf-o[cookies] only feeds the lavf stream backend. Instead of
side-loading it, use core `--cookies-file` option.
Introduces stream_http, an internal libcurl-driven backend for http://
and https:// URLs. Runs all transfers on a dedicated curl multi thread
with a producer-side ring buffer, and exposes HTTP/2 multiplexing,
QUIC/HTTP/3 (when libcurl supports it), HSTS and TCP keep-alive.

Should generally be more stable and faster than FFmpeg HTTP/1.1 impl,
additionally connections are kept-alive between files open, so if you
open playlist of network files and navigate through them, it will re-use
the same connection.

Build is gated on the new 'libcurl' meson option (auto). When disabled
or unavailable, mpv silently falls back to FFmpeg's HTTP implementation.
Hook AVFormatContext.io_open so HLS/DASH segment fetches and other
nested FFmpeg I/O go through stream_http when libcurl is available.
This lets segments inherit the connection reuse, HTTP/2 multiplexing,
mid-stream resume and conditional compression of the top-level stream.

Falls back to FFmpeg's default I/O for non-HTTP URLs and when the curl
backend is not built in.
Allow only subset of supported protocols by libcurl.
At the initial file open, the buffer may be populated with more data,
than later requested by decoder, but don't drop this data. This fixes
initial open to perform multiple reads of the area, especially for
images that are likelly fully read for probbing already.
It's significantly more stable than Lavf. Fixes seeking out of cached
ranges. Additionally correctly marks demuxer_is_network for ftp too.
@na-na-hi
Copy link
Copy Markdown
Contributor

Can you limit this to curl backend only? ffmpeg does not sensibly try to search for system CA store, so in practice nothing works unless manually specifying CA file.

@Andarwinux
Copy link
Copy Markdown
Contributor

ffmpeg does not sensibly try to search for system CA store

This depends on the TLS backend. schannel clearly will use CA store, while for openssl, on Linux, distributions usually handle it. By the way, Windows CI builds all use schannel, and although zhongfly builds use openssl, it has been patched to use CA store by default.

Can you limit this to curl backend only?

There is no difference. When curl is built with schannel backend, CA store is used by default, whereas built with openssl backend, CA store is not used unless curl is built with CURL_CA_NATIVE=ON.

@kasper93
Copy link
Copy Markdown
Member Author

kasper93 commented May 12, 2026

Can you limit this to curl backend only? ffmpeg does not sensibly try to search for system CA store, so in practice nothing works unless manually specifying CA file.

I posted this more as a RFC, because I'm aware some broken systems may have issues with this. However, https is prevalent and having broken CA store or not usable is rather user error at this point in time.

FYI, I was recently testing all things with this option enabled, which also affects ffmpeg, and it works fine, but I indeed use schannel on Windows.

We could set explicit CA to ffmpeg if curl is linked in, to the same file. There are still issues that we use http.c from lavf in some cases, because of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23071.

All in all, I would prefer to have it enabled, even if it cause breakage. I know it sucks, but user can mitigate it, by updating their settings. Also some remaining issues may be resolved on the packaging side.

@kasper93
Copy link
Copy Markdown
Member Author

kasper93 commented May 12, 2026

Note that FFmpeg will enable TLS verification on next major version bump. FFmpeg/FFmpeg@5621eee

And version bump is coming with big steps https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22455

@na-na-hi
Copy link
Copy Markdown
Contributor

while for openssl, on Linux, distributions usually handle it.
I posted this more as a RFC, because I'm aware some broken systems may have issues with this. However, https is prevalent and having broken CA store or not usable is rather user error at this point in time.

This affects all linux systems out of box. Certificate package is already installed. But CA search still needs to be handled by curl or tls library.

whereas built with openssl backend, CA store is not used unless curl is built with CURL_CA_NATIVE=ON.

This is where the issue is. mpv should let curl search for CA store for openssl backend, and only enables tls verify be default if this can be done.

Note that FFmpeg will enable TLS verification on next major version bump. FFmpeg/FFmpeg@5621eee

This is only done after FFmpeg/FFmpeg@080dc4c which lets it search for CA so tls verify works by default. The option should not be enabled by default on older versions.

@kasper93
Copy link
Copy Markdown
Member Author

This affects all linux systems out of box. Certificate package is already installed. But CA search still needs to be handled by curl or tls library.

So it's package issue of libcurl, not ours.

This is where the issue is. mpv should let curl search for CA store for openssl backend, and only enables tls verify be default if this can be done.

I don't think this is valid. This breaks expectation that TLS is verified. We do verify when we feel like it? It should be the conscious decision of the user to either disable verification or fix CA.

This is only done after FFmpeg/FFmpeg@080dc4c which lets it search for CA so tls verify works by default. The option should not be enabled by default on older versions.

Sure, I will gate it with the same api level.

@na-na-hi
Copy link
Copy Markdown
Contributor

So it's package issue of libcurl, not ours.

curl can search for native CA store with --ca-native. Packages are not obligated to hardcode a default CA path for libcurl when client API users can configure CA store searching.

I don't think this is valid. This breaks expectation that TLS is verified. We do verify when we feel like it? It should be the conscious decision of the user to either disable verification or fix CA.

This is similar to the ffmpeg situation. If curl can attempt to perform CA search then tls verify should be enabled by default. If it is not supported then it should be disabled.

@kasper93
Copy link
Copy Markdown
Member Author

This is similar to the ffmpeg situation. If curl can attempt to perform CA search then tls verify should be enabled by default. If it is not supported then it should be disabled.

I can enable CURLSSLOPT_NATIVE_CA, no problem.

@kasper93
Copy link
Copy Markdown
Member Author

Updated, now it enabled by default only when libcurl is used or for lavf > 63

@Andarwinux
Copy link
Copy Markdown
Contributor

It would be best to log a warning when tls-verify cannot be enabled by default.

@kasper93
Copy link
Copy Markdown
Member Author

It's build time check, not sure it's worth logging that. Eventually it will go away as mpv migrates to libcurl and ffmpeg itself is updated. In the meantime it remains as it were, disabled.

kasper93 added 2 commits May 12, 2026 14:48
This is independent of other CA certificate locations set at run time or
build time. Those locations are searched in addition to the native CA
store.
We shouldn't default to no verification in current year. User can
opt-out if needed.

Keep it disable for builds without libcurl when libavformat is older
than 63.0.100. This is done to match ffmpeg's timeline for enabling
tls_verify by default in lavf, also to ensure we the default verify
locations will be loaded on such version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants