Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support swift Package Manager #4915

Open
WesleyRosenblum opened this issue Nov 19, 2024 · 2 comments
Open

Support swift Package Manager #4915

WesleyRosenblum opened this issue Nov 19, 2024 · 2 comments

Comments

@WesleyRosenblum
Copy link
Contributor

WesleyRosenblum commented Nov 19, 2024

Issue opened on behalf of @waahm7

Problem:

aws-crt-swift is a Swift package that depends on s2n-tls on Linux. Unfortunately, Swift Package Manager doesn't support CMake (see swiftlang/swift-package-manager#4555), and we have a minimal s2n-tls configuration that was working before the following change: #4465.

Our Swift Configuration: https://github.com/awslabs/aws-crt-swift/blob/main/Package.swift#L95

packageTargets.append(.target(
    name: "S2N_TLS",
    dependencies: ["LibCrypto"],
    path: "aws-common-runtime/s2n",
    exclude: s2nExcludes,
    publicHeadersPath: "api",
    cSettings: [
        .headerSearchPath("./"),
        .define("POSIX_C_SOURCE=200809L"),
        .define("S2N_NO_PQ")
    ]
))

Without using CMake, we are not able to build. We would prefer if S2N can provide an official Swift package so that it is configured properly with all the features., as the expected s2n_prelude.h file is not put in place and all feature probes are not running, amongst other missing build logic:

/root/aws-crt-swift/aws-common-runtime/s2n/tls/s2n_config.c:18:6: error: "Expected s2n_prelude.h to be included as part of the compiler flags"
    #error "Expected s2n_prelude.h to be included as part of the compiler flags"

Swift Package Manager doesn’t have a lot of configuration options and just builds the C package with a lot of assumptions. You can’t use any compiler flags, etc. We just wrote the minimum config needed to get it working.

Solution:

We would prefer if S2N can provide an official Swift package so that it is configured properly with all the features.

We can't replicate the build logic from CMake, since SwiftPM doesn’t allow unsafe compiler flags. See: here and here.

As some build flags can be exploited for unsupported or malicious behavior, the use of unsafe flags makes the products containing this target ineligible for use by other packages.

We are thinking about working around this problem by just defining the macros from s2n_prelude.h and having a CI that checks whether s2n_prelude.h has changed so that we can stay up-to-date with the changes.

  • Does this change what S2N sends over the wire? No
  • Does this change any public APIs? No
  • Which versions of TLS will this impact? n/a

Requirements / Acceptance Criteria:

What must a solution address in order to solve the problem? How do we know the solution is complete?

aws-crt-swift is able to build s2n-tls correctly, including all feature probes being executed.

  • RFC links: n/a
  • Related Issues: linked inline
  • Will the Usage Guide or other documentation need to be updated? yes
  • Testing: TBD
    • Will this change trigger SAW changes? no
    • Should this change be fuzz tested? no

Out of scope:

Is there anything the solution will intentionally NOT address?

@maddeleine
Copy link
Contributor

Note: for this issue we need an investigation into what can be done here. None of us are swift experts so if there's a solution that doesn't involve creating a swift s2n package, that would be ideal.

@sbSteveK
Copy link

+1 on this request/issue from the AWS IoT Device SDK team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants