Implement TLS for linux and macos#863
Closed
sstone wants to merge 5 commits into
Closed
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).