Repository navigation
rtmp-services: Stream over RTMPS where the ingest server accepts it - #2219
Conversation
|
Coordinator: I've turned auto-merge off on this for now. The maintainer needs to sign off on the timing of the RTMPS default before it lands. There's also a Format check failure to fix. I'll turn auto-merge back on once it's cleared. |
|
Coordinator: I took this out of the merge queue again. The hold above still applies until the maintainer signs off on the timing; the Format failure looks fixed, thanks. Please don't queue it yet. I'll queue it once the hold clears. |
|
Understood, I'll leave it out of the queue until the hold clears. Sorry for re-queuing it: I missed the hold comment after the Format fix. CI is green on 9e0c8cc. |
|
Coordinator: this was queued again, probably by an automated coordinator. I took it out and converted it to a draft, so nothing can queue it until the maintainer signs off on the timing. I'll mark it ready and queue it once they have. |
…lback Built-in services whose ingest servers accept RTMPS should connect over it, and the frontend should be able to fall back to plain RTMP when the encrypted connection fails. - test_rtmps_upgrade loads the real rtmp-services module. A built-in service on a verified host connects to rtmps://<host>:443 with the same path, and reports the plain URL through the module's rtmp_services_rtmps_fallback command. rtmp_services_set_plain_rtmp switches it back to the plain URL. Unlisted hosts, other services, other ports, custom servers and rtmps:// servers stay as they are. - test_rtmps_fallback_dialog runs the "Proceed anyway" dialog on Qt's offscreen platform. It accepts on its own after the three-second countdown, its progress bar follows the countdown, a click accepts at once, Cancel stops the countdown, and a fallback is written to stderr and the OBS log. The upgrade list (rtmps-upgrade.c.h) and the dialog are no-op stubs here, so five upgrade cases and three dialog cases fail. Refs obs-rust#2205.
Built-in services whose ingest servers accept RTMPS on port 443 now connect over it. tools/rtmps-endpoint-check.py checked every server of every built-in RTMP service and Twitch's ingest list without an account: TLS with a valid certificate, the RTMP handshake and connect, and a made-up stream key rejected the same way as over plain RTMP. All servers of Twitch, Vimeo, niconico, BoxCast, Bitmovin, Eventials and EventLive.pro passed; rtmps-upgrade.c.h lists their hosts. The list is in code because services.json is replaced at runtime by the services update feed. rtmp_common_url() hands out rtmps://<host>:443/<path> for a listed host on the default port and keeps the plain URL. The stored server is unchanged, so existing profiles switch too. Custom servers, other ports, rtmps:// servers and unlisted hosts stay as they are. When an upgraded stream fails to connect, the frontend shows OBSRtmpsFallback: "Proceed anyway" counts down three seconds and then restarts the stream over plain RTMP unless the user cancels, and the fallback goes to stderr and the log. With the window hidden the countdown runs with a tray notice. The next start tries RTMPS again; multitrack video keeps its own URLs. The frontend reaches the service through two global proc handler commands rtmp-services registers (rtmp_services_rtmps_fallback, rtmp_services_set_plain_rtmp), since obs_service_get_proc_handler() is not exported. Fixes obs-rust#2205.
The frontend should retry a failed RTMPS start over plain RTMP only for a connection failure: a timeout, a refused or reset connection, or a handshake that fails for another reason. A server certificate that does not verify, also one issued for another host name, should stop the start (docs/fallback-warning.md rule 7). test_rtmps_cert_no_fallback builds the real rtmp-stream.c and librtmp and connects to a TLS listener on the loopback interface. The listener presents a certificate the test makes at run time for another host, once trusted (only the host name is wrong) and once untrusted. Both must be reported through the RTMP output's rtmp_tls_cert_unverified proc. A listener that closes the connection during the handshake, and a port with nothing listening, must not be. The output has no such proc yet, so all four cases fail. Refs obs-rust#2205.
The RTMPS fallback now raises the shared fallback warning (obs_frontend_warn_fallback, obs-rust#2218) instead of its own OBSRtmpsFallback dialog, which is removed with its unity group, precompiled header and strings. utility/RtmpsFallback.hpp raises it with Cancel, the standard wording (title "Streaming unencrypted (RTMP)", the message in the order what failed, what OBS does instead, what the user can do) and the plain URL, and passes the answer on: the countdown or "Accept anyway" restarts the stream over plain RTMP, Cancel stops the start. The warning logs the fallback at error level and to stderr. Two choices keep the first draft's behaviour until they are decided, as constants in RtmpsFallback.hpp. The shared warning asks once per id in a session, so the id names the server (IdPerServer). With the main window hidden, OBS still shows a tray notice and waits three seconds before it restarts (CountdownWhenHidden). The fallback now covers connection failures only. The RTMP output records whether its last connect failed because the server's certificate did not verify (MBEDTLS_ERR_X509_CERT_VERIFY_FAILED, also for a host-name mismatch) and reports it through the output proc rtmp_tls_cert_unverified. Then the frontend shows the connection error and logs the reason instead of offering plain RTMP. test_rtmps_fallback_warning replaces test_rtmps_fallback_dialog: the warning is raised with the right id, title, message and Cancel, its answer is passed on, only a connection failure of a service stream falls back, and the strings follow the standard wording. Refs obs-rust#2205.
When the system has no trusted root certificates, no RTMPS connection can be verified. The fallback to plain RTMP stays, but its warning now says why, in the standard order: OBS could not find the system's trusted certificates, so it could not make a secure connection; it streams unencrypted over RTMP instead; to stream encrypted, install the system's CA certificates package, or select Cancel. Other connection failures keep the normal message. The warning has its own id, rtmp.unencrypted.nocerts:<plain URL>, so it shows once per server in a session even after an ordinary failure was shown. The RTMP output's rtmp_tls_cert_unverified proc becomes rtmp_tls_failure(out string failure): "cert_unverified", "no_root_certs", or "" for anything else. "no_root_certs" is a handshake that failed certificate verification (or found no CA chain) while RTMP_TLS_LoadCerts loaded no certificates. A certificate that does not verify against loaded roots still stops the start. test_rtmps_cert_no_fallback checks an empty and a missing trust store (both "no_root_certs"), and a reset handshake with an empty store (an ordinary failure). test_rtmps_fallback_warning checks the causes, the id and the message of the no-certificates warning, and its wording. Refs obs-rust#2205.
zackees
left a comment
There was a problem hiding this comment.
Reviewed the current head against master (~1,970 added lines, 5 commits). No blockers — the shape is right and the ledger line is there. Two should-fix findings, both about the fallback happening without the user knowing, plus what I checked and found correct.
Should fix
1. A stale rtmpsFallbackRestart can silently downgrade a later, ordinary start — frontend/widgets/OBSBasic_Streaming.cpp.hpp:468, consumed at :74.
rtmpsFallbackRestart = true;
QMetaObject::invokeMethod(this, &OBSBasic::StartStreaming, Qt::QueuedConnection);StartStreaming() returns early at :45 (if (outputHandler->StreamingActive() || streamingStarting) { return; }) and at :49 (if (disableOutputsRef) { ... return; }), both before the flag is read and cleared at :74-75:
SetPlainRtmp(rtmpsFallbackRestart);
rtmpsFallbackRestart = false;The restart lambda only tests isClosing() || outputHandler->StreamingActive(), and StreamingActive() is false for the whole RTMPS handshake (BasicOutputHandler sets streamingActive from the output's start signal, not on StreamingPreparing). So if a start is in flight when the queued restart — or the 3-second hidden-window timer — fires (a hotkey, a tray start or an obs-websocket StartStream during that window is enough), the flag stays set and the next ordinary user-initiated start calls SetPlainRtmp(true): RTMP, no dialog, no tray notice, nothing in the log, and it sticks until restart. That is the one thing docs/fallback-warning.md rule 1 exists to prevent. Cheapest fix: also bail on streamingStarting in the lambda, or clear the flag on StartStreaming()'s early-return paths.
2. test_rtmps_upgrade can pass with zero assertions — test/cmocka/tests.d/test_rtmps_upgrade.cmake:20.
add_test(NAME test_rtmps_upgrade COMMAND test_rtmps_upgrade)This is the only test of the allowlist and the upgrade URL, and it needs a display: test_rtmps_upgrade.c:285 does if (!obs_startup("en-US", SERVICES_DATA_DIR "/services.json", NULL)) { fprintf(stderr, "cases skipped: obs_startup failed (no display?)\n"); return 0; }, and on that path the module never loads, so every case goes through SKIP_WITHOUT_MODULE() and ctest records PASS. The fragment's own comment says "run under xvfb-run, as Tier 2 does", but it does not wrap the command the way the sibling fragments do — test/cmocka/tests.d/test_output_protocol_null.cmake:
find_program(XVFB_RUN xvfb-run)
if(OS_LINUX AND XVFB_RUN)
add_test(NAME test_output_protocol_null COMMAND ${XVFB_RUN} -a -s "-screen 0 1280x1024x24 -noreset" $<TARGET_FILE:test_output_protocol_null>)Copy that shape (and the else() fallback) so the suite that guards the upgrade actually runs.
Checked, and correct
- Hidden main window accepting at once is policy, not a bug.
RtmpsFallback::Warnansweringaccepted=truewith no window shown (rust/obs-fallback-warning/src/lib.rs:if !window_visible { return Show::AcceptNow; }) is exactlydocs/fallback-warning.mdrule 5 ("with a hidden main window (OBS started to the tray), the warning accepts at once"), andOfferRtmpsFallbackdoes the tray notice plus a countdown for that case. I flagged it first and then found the rule, so: fine as written. - Nothing that streams today stops streaming.
rtmps_upgrade_url()requires the plain scheme, the default port only (UPGRADE_FROM_PORT "1935"; any explicit other port returns false) and an exact host match in the allowlist, andrtmp_common_get_protocol()still reports RTMP, so output-type selection is untouched. Custom servers and services with no verified host keep the plain URL. - A certificate that does not verify does not fall back (rule 7), and an empty trust store is distinguished from a verify failure rather than treated as one.
- The ledger line is present and accurate (
docs/features.md, "All, pending merge", with the seven services and the three-second fallback), and the locale keys the new strings use are defined infrontend/data/locale/en-US.ini.
Say when you want it queued — with the two findings fixed I'll watch the merge queue.
|
Coordinator review point, to hold before this leaves draft (the maintainer's timing sign-off still gates it — this is a merge condition on top of that, not a request to queue it): Fall back only when the connection cannot be made, never when the certificate does not verify. @vpacher raised this on #2205 on 10-24 and it is not yet in the branch: Concrete shape:
Also, per the fallback dialog: use the shared warning from #2238 rather than |
|
Coordinator note on the review point of 2026-10-27 (the fallback condition above), with no change to the maintainer's timing hold and no request to queue: The certificate-rejection result code is handled in a separate change, so this PR does not need to touch it. That change makes a failed certificate verification report So the merge condition stands as: fall back only when the connection cannot be made (timeout, refused, unreachable), never on a certificate that does not verify. Nothing else changes; the hold at the top of this thread is unaffected. |
The unity group compiles rtmp-common.c.h before rtmp-services-main.c.h, so the extern declaration in main came after the definition and GCC failed the merge-queue build with -Werror=missing-prototypes (obs-rust#2219). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Coordinator: the asan lane fails on this PR's new test. LeakSanitizer reports 7 leaks in |
RTMP_AddStream copies the key, but RTMP_Close frees it for a publishing connection only after a redirect, and RTMP_Init forgets it. A failed RTMPS start (test_rtmps_cert_no_fallback) leaked it under LeakSanitizer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #2205
What and why
Built-in services whose ingest servers accept RTMPS now stream over it (port 443) instead of plain RTMP. If the encrypted connection fails, OBS offers plain RTMP with a three-second countdown.
tools/rtmps-endpoint-check.py(new) checked every server of every built-in RTMP service, plus Twitch's ingest list and its built-in fallback: 466 servers, over plain RTMP and over RTMPS on the same host. Each check covered DNS, a valid certificate for the host name, the RTMP handshake andconnectover TLS, and a publish with a made-up stream key, which must be rejected the same way over both protocols. No media is sent. All servers of seven services passed: Twitch (61 hosts), Vimeo, niconico, BoxCast, Bitmovin, Eventials and EventLive.pro. Their hosts are listed inplugins/rtmp-services/service-specific/rtmps-upgrade.c.h. Services we could not verify stay on plain RTMP and are listed in rtmp-services: Services with possible RTMPS support that #2205 could not verify #2216, with what each one needs.rtmp_common_url()hands outrtmps://<host>:443/<same path>for a listed host on the default port. The list lives in code becauseservices.jsonis replaced at runtime by the copy from the services update feed. The server the user picked is still stored as is, so existing profiles switch with nothing to change, and the dropdowns are unchanged. Custom servers, other ports,rtmps://servers and unlisted hosts stay as they are. Without an RTMPS-capable output, nothing changes.obs_frontend_warn_fallback, merged in frontend: Shared fallback warning with a countdown (obs_frontend_warn_fallback) #2238) instead of the error box, withcan_cancel = true. It uses the standard wording fromdocs/fallback-warning.md: the title Streaming unencrypted (RTMP), and a message saying what failed (no encrypted connection), what OBS does instead (streams to<server>unencrypted), and what the user can do (Cancel, or allow port 443). The buttons are the shared Accept anyway and Cancel. The three-second countdown accepts on its own, so a stream started from obs-websocket or--startstreamingstill goes live, and Cancel stops the start. The warning writes the fallback to the log at error level and to stderr. Accepting restarts the stream over plain RTMP. The next start the user asks for tries RTMPS again, and reconnects keep the URL the stream started with. Multitrack video (Enhanced Broadcasting) brings its own URLs, so it never offers the fallback. The PR's ownOBSRtmpsFallbackdialog, its unity group and its strings are gone.MBEDTLS_ERR_X509_CERT_VERIFY_FAILED, which is also how Mbed TLS reports a certificate for another host name), the start stops with the usual connection error and the reason in the log. The RTMP output records the cause on connect and reports it through a new output proc,rtmp_tls_failure(out string failure):"cert_unverified","no_root_certs", or""for anything else. The frontend asks it before offering the fallback.Output.RtmpsFallback.NoRootCerts, and the warning its own id,rtmp.unencrypted.nocerts:<plain URL>. Other failures keep the normal message.rtmp.unencrypted:<plain URL>). A second failure to the same server in the same session only logs and continues over RTMP.rtmp_services_rtmps_fallback(in ptr service, out string plain_url)andrtmp_services_set_plain_rtmp(in ptr service, in bool enabled).obs_service_get_proc_handler()is not exported.rtmp-streamstill turns off "Enable network optimizations" (and low-latency mode) forrtmps://URLs. Both are off by default; users who turned them on lose them on the upgraded services, as they already did on YouTube - RTMPS and Facebook.RED → GREEN
test: Expect RTMPS for verified ingest servers, with a plain RTMP fallback.test_rtmps_upgradeloads the real rtmp-services module: 5 of 9 cases fail.module_listed_server_connects_over_rtmps,module_listed_server_reports_plain_fallback,module_plain_rtmp_after_fallback,module_other_port_stays_plainandmodule_host_case_and_queryget the plain URL. The four "stays as it is" cases pass before and after.test: Stop an RTMPS start whose certificate does not verify.test_rtmps_cert_no_fallbackbuilds the realrtmp-stream.cand librtmp and connects to a TLS listener on the loopback interface that presents a certificate made at run time for another host. 4 of 4 fail: the output has no way to report the certificate failure. Cases: a trusted certificate for another host (only the host name is wrong) and an untrusted one must report it. A listener that closes the connection during the handshake, and a port with no listener, must not.frontend: Use the shared fallback warning for RTMPS, then 6c4f0f6frontend: Say when RTMPS failed for lack of trusted root certificates. RED for the second, run locally against b24bc94's code: the three new trust-store cases oftest_rtmps_cert_no_fallbackfail (as do the four earlier ones, since the proc becamertmp_tls_failure), andwording_follows_the_standardfails on the missingNoRootCertsstring.test_rtmps_upgrade9/9,test_rtmps_cert_no_fallback7/7 andtest_rtmps_fallback_warning8/8 pass, none skipped.test_rtmps_cert_no_fallbackbuilds the realrtmp-stream.cand librtmp against a TLS listener on the loopback interface. It covers: a trusted certificate for another host and an untrusted one (cert_unverified); a reset handshake and a refused port (""); an empty and a missing trust store (no_root_certs); and a reset handshake with an empty store ("").test_rtmps_fallback_warningreplaces the dialog test. It checks the id, title, message (with the URL) andcan_cancel = truefor both warnings, that the answer is passed on once, the cause strings, that only a connection failure of a service stream falls back (also without root certificates, never for an unverified certificate), and that both messages follow the standard wording and order.test_fallback_warning_dialog,test_fallback_warning_queue,test_frontend_warn_fallback,test_rtmp_send_thread_leak,test_rtmp_dbr_user_bitrate,test_rtmp_error,test_file_updater_failure,test_ingest_refresh_wait,test_service_encoder_settingsandtest_stream_service_selectstill pass.ci/test_*.pysuite, cargo fmt) clean; test-diff (obs-build, obs-studio-rust, obs-sys) 66/66; cross clean.--startstreaming, private network namespace with nothing on port 443) showed the old dialog. It has not been repeated with the shared warning yet.Checklist
masterdocs/features.mdis added-W..., ratchets): none