Skip to content

Implement TLS for linux and macos#863

Closed
sstone wants to merge 5 commits into
masterfrom
linux-apple-tls
Closed

Implement TLS for linux and macos#863
sstone wants to merge 5 commits into
masterfrom
linux-apple-tls

Conversation

@sstone

@sstone sstone commented Jul 2, 2026

Copy link
Copy Markdown
Member

This is a rebase of #860 on top of #861.
It provides TLS implementation for linux (based on ruslt-ffi) and macos (re-using the original ios code that calls apple libraries).

pm47 and others added 5 commits July 2, 2026 14:25
Kotlin/Native's Ktor sockets don't support TLS on native targets, so
macOS fell back to KtorNoTlsTcpSocket and hit a TODO("TLS not
supported") whenever TLS was requested (e.g. Electrum over TLS).
iOS already worked around this by wrapping the Network.framework-based
NativeSocket (Swift, in the PhoenixCrypto module) instead of Ktor.

Move that implementation from iosMain into a shared appleMain source
set (renaming IosTcpSocket -> AppleTcpSocket) so both iOS and macOS
resolve TcpSocket's PlatformSocketBuilder to it. Wire the PhoenixCrypto
cinterop and Xcode build for macosX64/macosArm64:

- add a buildCryptoMacosx Gradle task that builds PhoenixCrypto against
  the macosx SDK (with an explicit CONFIGURATION_BUILD_DIR, since macOS
  doesn't get the -<platform> suffix on its build dir that the iOS SDKs
  do)
- add macos_x64/macos_arm64 linker options to PhoenixCrypto.def
- re-enable the Electrum/integration tests on macosX64Test/
  macosArm64Test that were previously skipped for lack of TLS support

Linux is unaffected: it keeps using KtorNoTlsTcpSocket with TLS disabled.
iosMain only contained AtomicOnce.kt, which is unused — delete it.

Use a single ktor-client-darwin dependency in appleMain instead of
ktor-client-ios/ktor-client-darwin in iosMain/macosMain: the Darwin
engine supports all Apple targets, and the engine is auto-discovered
so no code changes are needed.
We add a cinterop wrapper for rustls-ffi to implement TLS for linux sockets.
rustls-ffi provides c-binding for rustls, a TLS implementation written in rust.
@sstone sstone changed the title Implenment TLS for linux and macos Implement TLS for linux and macos Jul 2, 2026
@sstone sstone closed this Jul 2, 2026
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.

2 participants