Skip to content

feat(mobile-control): support https/wss for direct server URLs when Secure is true - #1450

Open
jkdevito wants to merge 1 commit into
mainfrom
feature/mobile-control-https-wss-support
Open

feat(mobile-control): support https/wss for direct server URLs when Secure is true#1450
jkdevito wants to merge 1 commit into
mainfrom
feature/mobile-control-https-wss-support

Conversation

@jkdevito

Copy link
Copy Markdown
Contributor

Closes #1449

Summary

Implements docs/mobile-control-https-wss-support-plan.md: when directServer.Secure is true, Mobile Control's direct server now advertises https:///wss:// URLs instead of hardcoded http:///ws://.

Changes

  • PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs
    • Added HttpScheme/WsScheme helper properties driven by _parent.Config.DirectServer.Secure.
    • Replaced hardcoded scheme literals throughout: app URL, WS URL, API path, remote logging URL, JoinResponse.UserAppUrl.
    • HttpServer constructor now passes _parent.Config.DirectServer.Secure instead of a hardcoded false.
    • EnabledSslProtocols set to SslProtocols.Tls12 only (Tls13 is not defined for net472; dropped legacy Tls11).
  • PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.cs
    • GetUrlWithCorrectIp regexes updated to capture and preserve the scheme (http/https) instead of assuming http.

Testing

Validated on real hardware (TS-1070 running Crestron's Zoom Room Controller app):

  • With directServer.Secure: true, the server now advertises https://<processor>:<port>/mc/app?token=…&authToken=… and the URL loads over TLS (confirmed via curl -kv / openssl s_client and in a desktop browser).
  • The authToken JWT auth layer generated alongside the URL was exercised end-to-end.
  • Confirmed this change is not itself the blocker for displaying Mobile Control inside the Zoom Room Controller's CH5 webview — that's a separate, expected frame-src 'self' CSP restriction on cross-origin iframing (tracked in mobile-control-zrc-wrapper-app's integration docs; the fix there is an app-level "Option B" architecture change, not an Essentials change).

Known follow-ups (not blocking this PR)

  • Processor's self-signed cert (selfCres) has a SAN defect: the IP is encoded as a DNS: SAN entry rather than an IPAddress: SAN entry. Worth fixing at the cert-generation source for stricter TLS clients.
  • Cert trust inside the Zoom Room webview's wss:// connection is not yet independently re-verified from a clean browser/device context.

Marked as draft pending final hardware sign-off (cert-trust re-verification above).

…ecure is true

- Add HttpScheme/WsScheme helpers driven by directServer.Secure
- Replace hardcoded http/ws literals in UserAppUrlPrefix, touchpanel app URL,
  _config.local.json ApiPath, remote logging POST, join-response WebSocketUrl
  and UserAppUrl
- Pass Secure flag into the HttpServer constructor so the listener actually
  negotiates TLS when a cert is configured
- Drop TLS 1.1 from EnabledSslProtocols, keep TLS 1.2 (TLS 1.3 is not defined
  in the net472 SslProtocols enum used by this project)
- MobileControlTouchpanelController: rewrite the app-URL IP regex to match
  and preserve either http or https instead of assuming http
@andrew-welker
andrew-welker marked this pull request as ready for review July 27, 2026 17:59
Copilot AI review requested due to automatic review settings July 27, 2026 17:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the Mobile Control direct server so that when directServer.Secure is enabled, all advertised client URLs use https:// and wss:// (instead of hardcoded http:// / ws://), aligning the emitted URLs with the server’s TLS configuration.

Changes:

  • Introduces HttpScheme / WsScheme helpers driven by DirectServer.Secure and replaces hardcoded schemes across generated URLs.
  • Passes DirectServer.Secure into the HttpServer constructor and restricts SSL protocols to Tls12.
  • Updates the touchpanel URL-rewrite regex to preserve an existing http/https scheme.

Reviewed changes

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

File Description
src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs Switches generated app/API/WS URLs to scheme-aware http/https + ws/wss and updates server TLS settings.
src/PepperDash.Essentials.MobileControl/Touchpanel/MobileControlTouchpanelController.cs Preserves http/https when rewriting URLs to the correct processor/CS LAN host IP.
Comments suppressed due to low confidence (1)

src/PepperDash.Essentials.MobileControl/WebSocketServer/MobileControlWebsocketServer.cs:501

  • ApiPath is using _parent.Config.DirectServer.Port, but the direct server may be listening on Port (e.g., when the configured port is 0 and the constructor falls back to 50000 + ProgramNumber). This can generate an API URL pointing at the wrong port. Use Port so the advertised API path matches the actual listener port.
                    ApiPath = string.Format("{0}://{1}:{2}/mc/api", HttpScheme, processorIp, _parent.Config.DirectServer.Port),

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

var appUrl = $"http://{ip}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}";
var appUrl = $"{HttpScheme}://{ip}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}";
res.Close();

var logRequest = new HttpRequestMessage(HttpMethod.Post, $"http://{_parent.Config.DirectServer.Logging.Host}:{_parent.Config.DirectServer.Logging.Port}/logs")
var logRequest = new HttpRequestMessage(HttpMethod.Post, $"{HttpScheme}://{_parent.Config.DirectServer.Logging.Host}:{_parent.Config.DirectServer.Logging.Port}/logs")
Comment on lines +522 to 526
var match = Regex.Match(url, @"^(https?)://([^:/]+):\d+/mc/app\?token=.+$");
if (match.Success)
{
string ipa = match.Groups[1].Value;
string ipa = match.Groups[2].Value;
// ip will be "192.168.1.100"
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.

Mobile Control: emit https/wss URLs when directServer.Secure is enabled

2 participants