Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/dot-github/workflo…
Browse files Browse the repository at this point in the history
…ws/aws-actions/configure-aws-credentials-4.0.2
  • Loading branch information
jmayclin authored Nov 21, 2024
2 parents ec60067 + ff4c487 commit f93159e
Show file tree
Hide file tree
Showing 20 changed files with 171 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
contents: read # This is required for actions/checkout
id-token: write # This is required for requesting the JWT
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_compliance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone s2n-tls
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Clone s2n-quic
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: aws/s2n-quic
path: ./s2n-quic
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
name: CI FreeBSD
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build and test in FreeBSD
id: test
uses: vmactions/freebsd-vm@v1
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/ci_linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
env:
CPPCHECK_INSTALL_DIR: test-deps/cppcheck
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup
run: source ./codebuild/bin/s2n_setup_env.sh
Expand All @@ -38,7 +38,7 @@ jobs:
headers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup
run: source ./codebuild/bin/s2n_setup_env.sh
Expand All @@ -49,7 +49,7 @@ jobs:
simple-mistakes:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup
run: source ./codebuild/bin/s2n_setup_env.sh
Expand All @@ -60,7 +60,7 @@ jobs:
comments:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup
run: source ./codebuild/bin/s2n_setup_env.sh
Expand All @@ -76,7 +76,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run autopep8
id: autopep8
uses: peter-evans/autopep8@v2
Expand All @@ -90,7 +90,7 @@ jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: clang-format check
uses: harrisonkaiser/clang-format-action@verbose
with:
Expand All @@ -100,7 +100,7 @@ jobs:
# The nix develop changes contain broken nixpkg dependenecies; the allow/impure flags workaround this.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: nixbuild/nix-quick-install-action@v29
with:
nix_conf: experimental-features = nix-command flakes
Expand All @@ -109,7 +109,7 @@ jobs:
nixfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: nixbuild/nix-quick-install-action@v29
with:
nix_conf: experimental-features = nix-command flakes
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/ci_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
matrix:
os: [ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Rust toolchain
id: toolchain
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:
harness-interop-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Rust toolchain
id: toolchain
Expand All @@ -105,7 +105,7 @@ jobs:
s2n-tls-binding-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Rust toolchain
id: toolchain
Expand All @@ -123,7 +123,7 @@ jobs:
generate-openssl-102:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Rust toolchain
id: toolchain
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
matrix:
os: [ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

Expand Down Expand Up @@ -213,7 +213,7 @@ jobs:
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

Expand All @@ -237,7 +237,7 @@ jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

Expand Down Expand Up @@ -267,7 +267,7 @@ jobs:
msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
# Enforce crate msrv matches rust-toolchain
Expand All @@ -283,7 +283,7 @@ jobs:
pcaps:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Check out GitHub Pages branch
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: 'gh-pages'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Create Documentation
run: |
.github/s2n_doxygen.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gha_osx_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout Dependencies
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Prebuild
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/private_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
if: contains(github.repository, 'aws/s2n-tls')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/proof_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
pull-requests: read
steps:
- name: Check out repository and submodules recursively
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Parse config file
Expand Down
3 changes: 3 additions & 0 deletions bindings/rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Generating rust bindings can be accomplished by running the `generate.sh` script
$ ./bindings/rust/generate.sh
```

This script generates the low-level bindings in the crate `s2n-tls-sys`, which is used by the `s2n-tls` crate to provide higher-level bindings.
See [s2n-tls-sys](https://github.com/aws/s2n-tls/blob/main/bindings/rust/s2n-tls-sys/README.md) for more information on `s2n-tls-sys` crate.

## Minimum Supported Rust Version (MSRV)

`s2n-tls` will maintain a rolling MSRV (minimum supported rust version) policy of at least 6 months. The current s2n-quic version is not guaranteed to build on Rust versions earlier than the MSRV.
Expand Down
38 changes: 36 additions & 2 deletions bindings/rust/s2n-tls-sys/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
This crates provides low level rust bindings for [s2n-tls](https://github.com/aws/s2n-tls) which are autogenerated with [bindgen](https://github.com/rust-lang/rust-bindgen)
This crate provides low level rust bindings for [s2n-tls](https://github.com/aws/s2n-tls) which are autogenerated with [bindgen](https://github.com/rust-lang/rust-bindgen)

This crate is not intended for direct consumption by end consumers. Interested developers should instead look at the [s2n-tls](https://crates.io/crates/s2n-tls) or [s2n-tls-tokio](https://crates.io/crates/s2n-tls-tokio) crates. These provide higher-level, more ergonomic bindings than the `s2n-tls-sys` crate.
This crate is not intended for direct consumption by end consumers. Interested developers should instead look at the [s2n-tls](https://crates.io/crates/s2n-tls) or [s2n-tls-tokio](https://crates.io/crates/s2n-tls-tokio) crates. These provide higher-level, more ergonomic bindings than the `s2n-tls-sys` crate.

The `s2n-tls-sys` bindings crate contains the raw C code of `s2n-tls`. By default, it follows this build process:

1. Use the system C compiler to build `libs2n.a`
2. Link the built `libs2n.a` to the Rust bindings
3. Link against `aws-lc` through the `aws-lc-rs` crate

## Bring your own libs2n with `s2n-tls-sys` crate

You can customize above build process to use your own pre-built libs2n. This is useful if you want the bindings to be built with a non-default libcrypto. Currently, the default libcrypto when generating rust bindings is `aws-lc`. Here's how you can do that:

1. Clone [s2n-tls](https://github.com/aws/s2n-tls) and compile your preferred configuration of s2n-tls.

You may choose to link against a specific libcrypto at this step. For more information, see [Building with a specific libcrypto](https://github.com/aws/s2n-tls/blob/main/docs/BUILD.md#building-with-a-specific-libcrypto).
Also see [Building s2n-tls](https://github.com/aws/s2n-tls/blob/main/docs/BUILD.md#building-s2n-tls) for further guidance on configuring s2n-tls for your own use case.

2. `cd` into your rust project and set environment variables to your libs2n artifacts.

This tells the bindings to link to pre-built libs2n when running the build script for s2n-tls-sys
```
export S2N_TLS_LIB_DIR=<PATH_TO_ROOT_OF_S2N_TLS>/build/lib
export S2N_TLS_INCLUDE_DIR=<PATH_TO_ROOT_OF_S2N_TLS>/api
export LD_LIBRARY_PATH=$S2N_TLS_LIB_DIR:$LD_LIBRARY_PATH
```

`S2N_TLS_LIB_DIR` points to the folder containing `libs2n.a`/`libs2n.so` artifact that you would like s2n-tls-sys to link against.
`S2N_TLS_INCLUDE_DIR` points to the folder containing header files for `libs2n.a`/`libs2n.so` artifact.
`LD_LIBRARY_PATH` adds the path to `libs2n.a`/`libs2n.so` artifact for dynamic linker's search path.

3. Build your project. This triggers the build script for s2n-tls-sys

```
cargo build
```
26 changes: 26 additions & 0 deletions codebuild/spec/buildspec_al2023_ktls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
# This is designed to work with CodeBuild's reserved instances fleet and curated Ec2 AMI for AL2023.
version: 0.2
env:
variables:
NIX_CACHE_BUCKET: "s3://s2n-tls-nixcachebucket-x86-64?region=us-west-2"
S2N_KTLS_TESTING_EXPECTED: 1
phases:
install:
commands:
- yum update -y; yum upgrade -y
pre_build:
commands:
# Nix is installed, but intentionally not setup for root, fix that
- cp -aR /home/nix/.nix-profile ~/; chown -R root /root/.nix-profile; export PATH=$HOME/.nix-profile/bin:$PATH
# Turn on flakes
- mkdir -p ~/.config/nix; echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
# Populate the store from the nix cache
- nix copy --from $NIX_CACHE_BUCKET --all --no-check-sigs
# Load the TLS kernel module
- sudo modprobe tls
- echo "Checking that the TLS kernel mod loaded..."; test $(sudo lsmod|grep -c tls) = 1
build:
commands:
- nix develop .#openssl111 --command bash -c 'source ./nix/shell.sh && clean && configure && unit'
- S2N_CMAKE_OPTIONS="-DASAN=ON" nix develop .#openssl111 --command bash -c 'source ./nix/shell.sh && clean && configure && unit'
14 changes: 0 additions & 14 deletions codebuild/spec/buildspec_generalbatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,17 +388,3 @@ batch:
privileged-mode: true
compute-type: BUILD_GENERAL1_LARGE
image: 024603541914.dkr.ecr.us-west-2.amazonaws.com/docker:ubuntu22codebuild
- identifier: ktls
buildspec: codebuild/spec/buildspec_ktls.yml
env:
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:7.0
privileged-mode: true
- identifier: ktlsASAN
buildspec: codebuild/spec/buildspec_ktls.yml
env:
compute-type: BUILD_GENERAL1_LARGE
image: aws/codebuild/standard:7.0
privileged-mode: true
variables:
S2N_CMAKE_OPTIONS: "-DASAN=ON"
4 changes: 2 additions & 2 deletions tests/unit/s2n_alerts_protocol_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ int main(int argc, char **argv)
case S2N_ERR_CERT_UNTRUSTED:
EXPECT_SUCCESS(s2n_connection_set_config(client, untrusted_config));

EXPECT_FAILURE_WITH_ERRNO(s2n_negotiate_test_server_and_client(server, client),
S2N_ERR_CERT_UNTRUSTED);
EXPECT_FAILURE_WITH_ALERT(s2n_negotiate_test_server_and_client(server, client),
S2N_ERR_CERT_UNTRUSTED, S2N_TLS_ALERT_CERTIFICATE_UNKNOWN);

failed_conn = client;
closed_conn = server;
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/s2n_mutual_auth_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ int main(int argc, char **argv)
EXPECT_SUCCESS(s2n_connection_set_io_pair(client_conn, &io_pair));
EXPECT_SUCCESS(s2n_connection_set_io_pair(server_conn, &io_pair));

EXPECT_FAILURE_WITH_ERRNO(s2n_negotiate_test_server_and_client(server_conn, client_conn),
S2N_ERR_CERT_UNTRUSTED);
EXPECT_FAILURE_WITH_ALERT(s2n_negotiate_test_server_and_client(server_conn, client_conn),
S2N_ERR_CERT_UNTRUSTED, S2N_TLS_ALERT_CERTIFICATE_UNKNOWN);

/* Ensure that a client certificate was received on the server, indicating that the
* validation error occurred when processing the client's certificate, rather than the
Expand Down
Loading

0 comments on commit f93159e

Please sign in to comment.