Skip to content

fix: replace semaphore deadlock pattern in SSH host key verification#592

Merged
datlechin merged 2 commits intomainfrom
fix/host-key-verifier-async
Apr 6, 2026
Merged

fix: replace semaphore deadlock pattern in SSH host key verification#592
datlechin merged 2 commits intomainfrom
fix/host-key-verifier-async

Conversation

@datlechin
Copy link
Copy Markdown
Member

Summary

  • HostKeyVerifier — Replaced DispatchSemaphore.wait() + DispatchQueue.main.async { alert.runModal() } pattern with proper async/await + @MainActor + beginSheetModal(for:). Eliminates thread blocking on Swift concurrency cooperative pool.
  • LibSSH2TunnelFactory — Made createTunnel, testConnection, buildAuthenticatedChain, and verifyHostKey all async throws to support the async verification flow.
  • SSHTunnelManager — Removed Task.detached wrappers (no longer needed since factory methods are async).
  • Fixed 2 String(localized:) with interpolation violations in host key prompt messages.

Addresses audit item C1 — the last remaining critical thread-safety issue.

Test plan

  • Connect to SSH server NOT in known_hosts → host key prompt appears as a sheet on the key window
  • Accept unknown host key → connection succeeds, key saved to known_hosts
  • Cancel unknown host key prompt → connection fails gracefully
  • Connect to SSH server with changed key → mismatch warning sheet appears
  • Accept changed key → connection succeeds, key updated
  • Cancel changed key prompt → connection fails
  • Connect to known SSH server → no prompt, connects directly
  • Connect through jump hosts → each hop prompts if unknown
  • Test SSH connection from Connection Form → works correctly
  • No UI freeze during host key prompts

@datlechin datlechin merged commit 51d0647 into main Apr 6, 2026
2 checks passed
@datlechin datlechin deleted the fix/host-key-verifier-async branch April 6, 2026 05:52
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.

1 participant