Feat(client): add TLS transport to the macOS client

macOS shares the Linux transport: TlsChannel.h now dispatches __APPLE__ to
the OpenSSL implementation, so handshake, pinned trust anchor, reload and
removal all come from client/TlsChannelLinux.cpp. Only the platform glue
is new: ConfigDir() follows initConfigPaths (HOME, then getpwuid(), then
/tmp; no XDG) so the anchor sits next to config.conf, and ExeDir() uses
_NSGetExecutablePath.

First connect stays plaintext. The operator turns TLS on from the online
list: COMMAND_TLS_ENABLE carries the anchor PEM, COMMAND_TLS_DISABLE
removes it. macos/main.mm saves the anchor, calls TlsReload() and only
reconnects when the transport actually changed, so re-saving the same
anchor does not drop a live session. RES_TLS is filled from TlsEnabled()
and refreshed on every reconnect; fillLoginInfo clears szReserved first
now, because AddReserved appends and it runs twice on a group change.

CMake builds arm64 only (deployment target 11.0) and links Homebrew
openssl@3 statically when libcrypto.a is present, so the binary carries
no Homebrew path dependency. Not built or run on a Mac yet: the Apple
branch was syntax-checked under WSL and the login refresh probe-tested;
macos/README.txt has the build and verify steps.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-14 11:43:30 +01:00
1 parent 3d87ec6720
commit b743de6747
12 files changed
+298 -38

No files matched your search

+27 -1
View File
@@ -4,6 +4,12 @@ macOS Remote Desktop Client
Prerequisites:
1. Xcode Command Line Tools: xcode-select --install
2. CMake: brew install cmake
3. OpenSSL (TLS transport): brew install openssl@3
CMake 自动探测 /opt/homebrew/opt/openssl@3,也可用
cmake .. -DOPENSSL_ROOT_DIR=/path/to/openssl 指定。
构建目标是 Apple Silicon (arm64) 单架构:Homebrew 的 OpenSSL 只有本机架构,
保留 x86_64 slice 会链接失败。Intel Mac 需另建 x86_64 的 OpenSSL 单独构建。
Build:
chmod +x build.sh
@@ -11,7 +17,7 @@ Build:
Or manually:
mkdir build && cd build
cmake ..
cmake .. -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0
make
Run:
@@ -21,6 +27,26 @@ Configuration:
Server address is configured in main.mm (g_SETTINGS variable).
Modify before building if needed.
TLS Transport:
Default is plaintext on first connect. The controller's host right-click menu
("TLS 传输") sends the trust anchor; the client stores it at
~/.config/ghost/yama-ca.pem, hot-reloads and reconnects over TLS 1.2
(fail-closed, pinned to that anchor). "取消TLS" deletes the file and
reconnects in plaintext. Existing sessions survive only if the transport does
not change (replacing the certificate keeps TLS).
Verify after building:
otool -L build/bin/ghost | grep -i ssl # 期望无输出:OpenSSL 已静态链接
tail -f /tmp/ghost.log
Startup prints one of:
[TLS] transport on first connect: plaintext (no trust anchor)
[TLS] transport on first connect: TLS (trust anchor present)
Clicking "TLS 传输" should log "TLS transport switched to TLS, reconnecting";
the host's TLS column in the online list then shows Y. "取消TLS" logs
"switched to plaintext" and the column flips back to N.
If the log says "trust anchor exists but failed to load", the client refuses
to connect (fail-closed) until the anchor is fixed or removed.
Permissions Required:
1. Screen Recording - System Settings > Privacy & Security > Screen Recording
2. Accessibility - System Settings > Privacy & Security > Accessibility