Skip to content

Fix mtls connection for notifications video stream#4427

Merged
bgoncal merged 2 commits intomainfrom
mtls-hls
Mar 10, 2026
Merged

Fix mtls connection for notifications video stream#4427
bgoncal merged 2 commits intomainfrom
mtls-hls

Conversation

@bgoncal
Copy link
Member

@bgoncal bgoncal commented Mar 10, 2026

Summary

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

@bgoncal bgoncal self-assigned this Mar 10, 2026
Copilot AI review requested due to automatic review settings March 10, 2026 09:52
@bgoncal bgoncal linked an issue Mar 10, 2026 that may be closed by this pull request
2 tasks
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to fix video streaming when mTLS (client certificate auth) is enabled, particularly for notification video playback and MJPEG streaming, by ensuring the right URLSession/Alamofire delegates are used and that AVFoundation uses custom URL loading when needed.

Changes:

  • Add an mTLS-capable Alamofire SessionDelegate for MJPEG streaming that also emits the response-boundary notification.
  • Update HomeAssistantAPI.VideoStreamer() to select the correct delegate when a client certificate is configured.
  • Enable AVFoundation custom URL loading for HLS streams when a client certificate is present (in addition to security exceptions).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Sources/Shared/API/MJPEGStreamer.swift Adds MJPEGCertificateSessionDelegate to combine mTLS handling with MJPEG response notifications.
Sources/Shared/API/HAAPI.swift Chooses MJPEG session delegate based on whether the server has a client certificate configured.
Sources/Extensions/NotificationContent/CameraStreamHLSViewController.swift Enables custom AVURLAsset URL loading when mTLS is configured so auth challenges can be handled.

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@632e73b). Learn more about missing BASE report.

Files with missing lines Patch % Lines
Sources/Shared/API/MJPEGStreamer.swift 0.00% 8 Missing ⚠️
Sources/Shared/API/HAAPI.swift 0.00% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4427   +/-   ##
=======================================
  Coverage        ?   42.62%           
=======================================
  Files           ?      265           
  Lines           ?    15577           
  Branches        ?        0           
=======================================
  Hits            ?     6640           
  Misses          ?     8937           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bgoncal bgoncal merged commit 7f61c46 into main Mar 10, 2026
15 checks passed
@bgoncal bgoncal deleted the mtls-hls branch March 10, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[mTLS] Notifications containing an image/HLS stream fail to load

2 participants