Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CI
on:
pull_request:
push:
branches: [main]
# release.yml runs this on the tagged commit before publishing
workflow_call:
permissions:
contents: read
jobs:
# Format, lint and test the library with each crypto provider
check:
strategy:
fail-fast: false
matrix:
provider: [crypto-ring, crypto-aws-lc]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Format
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy -p sfio-rustls-config --all-targets --features ${{ matrix.provider }} -- -D warnings
- name: Test
run: cargo test -p sfio-rustls-config --features ${{ matrix.provider }}
# The verifier tests in the tests crate, with each crypto provider
integration:
strategy:
fail-fast: false
matrix:
provider: [crypto-ring, crypto-aws-lc]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Clippy
run: cargo clippy -p tests --all-targets --no-default-features --features ${{ matrix.provider }} -- -D warnings
- name: Test
run: cargo test -p tests --no-default-features --features ${{ matrix.provider }}
# Build with the rust-version declared in lib/Cargo.toml
msrv:
strategy:
fail-fast: false
matrix:
provider: [crypto-ring, crypto-aws-lc]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust 1.85
uses: dtolnay/rust-toolchain@1.85
- name: Check
run: cargo check -p sfio-rustls-config --features ${{ matrix.provider }}
# Fail on any advisory against the dependencies
audit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-audit
run: cargo install cargo-audit --locked
- name: Audit
run: cargo generate-lockfile && cargo audit
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release
# Pushing a tag equal to the crate version (e.g. 0.4.1) publishes it to crates.io using trusted
# publishing: crates.io trusts this workflow, so no API token is stored in the repository
on:
push:
tags: ["*"]
permissions:
contents: read
jobs:
# every CI check must pass on the tagged commit
ci:
uses: ./.github/workflows/ci.yml
publish:
needs: ci
runs-on: ubuntu-latest
environment: crates-io
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Check the tag matches the crate version
run: |
version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "sfio-rustls-config") | .version')
if [ "$version" != "$GITHUB_REF_NAME" ]; then
echo "tag $GITHUB_REF_NAME doesn't match the crate version $version"
exit 1
fi
- name: Authenticate with crates.io
id: auth
uses: rust-lang/crates-io-auth-action@v1
- name: Publish
run: cargo publish -p sfio-rustls-config --features crypto-ring
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.4.1
* :bug: Remove a debug `println!` that wrote the client certificate verification result to stdout on every handshake of a server using authority-based client verification.
* :wrench: Set `rust-version` to 1.85, the minimum the current dependencies require.
* :wrench: Build the docs.rs documentation with the `crypto-ring` provider, since the crate requires one.
* :wrench: Run CI on every change, and publish releases from CI with crates.io trusted publishing.

# 0.4.0
* :wrench: Make `ring` or `aws-lc-rs` configurable via features

Expand Down
4 changes: 4 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
allow-unwrap-in-tests = true
allow-expect-in-tests = true
allow-panic-in-tests = true
allow-indexing-slicing-in-tests = true
21 changes: 18 additions & 3 deletions lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "sfio-rustls-config"
version = "0.4.0"
version = "0.4.1"
license = "MIT OR Apache-2.0"
edition = "2021"
description = "Configuration routines for Rustls used in libraries from Step Function I/O"
repository = "https://github.com/stepfunc/rustls-config"
readme = "README.md"
authors = ["Step Function I/O LLC <info@stepfunc.io>"]
rust-version = "1.74"
rust-version = "1.85"

[dependencies]
pem = { version = "^3.0" }
Expand All @@ -17,6 +17,10 @@ rustls = { version = "0.23", default-features = false, features = ["std", "loggi
rustls-pki-types = { version = "1.11.0" }
rustls-webpki = { version = "0.103.1", default-features = false, features = ["std"] }

[package.metadata.docs.rs]
# the crate requires exactly one crypto provider
features = ["crypto-ring"]

[features]
default = []
crypto-ring = ["rustls/ring", "rustls-webpki/ring"]
Expand All @@ -34,7 +38,18 @@ unused_crate_dependencies = "deny"
missing_copy_implementations = "deny"

[lints.clippy]
all = "deny"
all = { level = "deny", priority = -1 }
# no output except through the caller, and no panics in library code; clippy.toml allows
# unwrap, expect, panic and indexing in tests
print_stdout = "deny"
print_stderr = "deny"
dbg_macro = "deny"
unwrap_used = "deny"
expect_used = "deny"
panic = "deny"
indexing_slicing = "deny"
arithmetic_side_effects = "deny"
as_conversions = "deny"

[lints.rustdoc]
broken_intra_doc_links = "deny"
13 changes: 12 additions & 1 deletion lib/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Description

Configuration routines for [rustls](https://github.com/rustls/rustls) used by Step Function's commercial [DNP3](https://github.com/stepfunc/dnp3)
and [Modbus](https://github.com/stepfunc/rodbus) libraries.
and [Modbus](https://github.com/stepfunc/rodbus) libraries.

# Usage

Enable exactly one crypto provider, `crypto-ring` or `crypto-aws-lc`:

```toml
[dependencies]
sfio-rustls-config = { version = "0.4", features = ["crypto-ring"] }
```

Requires Rust 1.85 or later.
8 changes: 2 additions & 6 deletions lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl ClientCertVerifier for ClientNameVerifier {
.base_verifier
.verify_client_cert(end_entity, intermediates, now)?;

let res = match &self.verification {
match &self.verification {
ClientNameVerification::None => {
// we're done
Ok(verified)
Expand All @@ -130,11 +130,7 @@ impl ClientCertVerifier for ClientNameVerifier {
ClientNameVerification::SanOrCommonName(x) => {
self.verify_client_name(end_entity, x, true)
}
};

println!("client result: {res:?}");

res
}
}

fn verify_tls12_signature(
Expand Down
10 changes: 8 additions & 2 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ edition = "2021"
publish = false

[dependencies]
sfio-rustls-config = { path = "../lib", default-features = false, features = ["crypto-aws-lc"] }
tokio-rustls = { version = "0.26", default-features = false, features = ["aws-lc-rs"] }
sfio-rustls-config = { path = "../lib", default-features = false }
tokio-rustls = { version = "0.26", default-features = false }
tokio = { version = "1.44", features = ["test-util", "net", "rt", "macros"] }

# exactly one provider, as for the library
[features]
default = ["crypto-aws-lc"]
crypto-aws-lc = ["sfio-rustls-config/crypto-aws-lc", "tokio-rustls/aws-lc-rs"]
crypto-ring = ["sfio-rustls-config/crypto-ring", "tokio-rustls/ring"]

[[test]]
name = "test_verifiers"
path = "src/test_verifiers.rs"
Expand Down
Loading