Skip to content

Commit 2db6ce0

Browse files
Add rustls real socket test with TLS server and client implementation
- Created a new Rust package for testing rustls with real socket connections. - Added Cargo.toml with dependencies for rustls, rustls-rustcrypto, anyhow, log, and env_logger. - Implemented main.rs to set up a TLS server and client using rustls. - Included dummy certificate verification for testing purposes. - Added binary files for certificate and private key in DER format.
1 parent ed9e1e7 commit 2db6ce0

File tree

17 files changed

+1791
-1
lines changed

17 files changed

+1791
-1
lines changed

.github/workflows/esp32-test.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: ESP32 Test Build
2+
3+
on:
4+
# push:
5+
# branches: [ master ]
6+
# paths:
7+
# - 'validation/esp32-test/**'
8+
# - '.github/workflows/esp32-test.yml'
9+
# pull_request:
10+
# paths:
11+
# - 'validation/esp32-test/**'
12+
# - '.github/workflows/esp32-test.yml'
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Cache ESP-IDF
27+
uses: actions/cache@v4
28+
with:
29+
path: |
30+
~/.espressif
31+
/opt/esp
32+
key: ${{ runner.os }}-espidf-${{ hashFiles('validation/esp32-test/sdkconfig.defaults') }}
33+
restore-keys: |
34+
${{ runner.os }}-espidf-
35+
36+
- name: Install ESP-IDF
37+
uses: espressif/install-esp-idf-action@v1
38+
with:
39+
version: "v5.5.1"
40+
41+
- name: Set ESP-IDF environment
42+
run: |
43+
echo "ESP_IDF_TOOLS_INSTALL_DIR=/opt/esp" >> $GITHUB_ENV
44+
echo "ESP_IDF_PATH=/opt/esp/idf" >> $GITHUB_ENV
45+
46+
- name: Set up Rust
47+
uses: dtolnay/rust-toolchain@master
48+
with:
49+
toolchain: nightly
50+
components: rust-src
51+
52+
- name: Setup SCCache
53+
uses: mozilla-actions/[email protected]
54+
55+
- name: Cache Cargo
56+
uses: Swatinem/rust-cache@v2
57+
with:
58+
workspaces: "validation/esp32-test"
59+
60+
- name: Setup | ldproxy
61+
uses: taiki-e/cache-cargo-install-action@v2
62+
with:
63+
tool: ldproxy
64+
65+
- name: Build ESP32 test
66+
working-directory: validation/esp32-test
67+
run: |
68+
cargo build
69+
env:
70+
SCCACHE_GHA_ENABLED: "true"
71+
RUSTC_WRAPPER: "sccache"
72+
73+
- name: Upload build artifacts
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: esp32-test-build
77+
path: |
78+
validation/esp32-test/build/
79+
retention-days: 30
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Rustls Real Socket Test
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- 'validation/rustls-real-socket-test/**'
8+
- '.github/workflows/rustls-real-socket-test.yml'
9+
pull_request:
10+
paths:
11+
- 'validation/rustls-real-socket-test/**'
12+
- '.github/workflows/rustls-real-socket-test.yml'
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
test:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
28+
- name: Setup SCCache
29+
uses: mozilla-actions/[email protected]
30+
31+
- name: Cache Cargo
32+
uses: Swatinem/rust-cache@v2
33+
with:
34+
workspaces: "validation/rustls-real-socket-test"
35+
36+
- name: Run in release mode
37+
working-directory: validation/rustls-real-socket-test
38+
run: cargo run --release
39+
env:
40+
SCCACHE_GHA_ENABLED: "true"
41+
RUSTC_WRAPPER: "sccache"
42+
43+
- name: Upload build artifacts
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: rustls-real-socket-test-release
47+
path: |
48+
validation/rustls-real-socket-test/target/release/
49+
retention-days: 30

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ rand_core = { version = "0.9.3", default-features = false, features = [
5454
rustls = { version = "0.23.31", default-features = false }
5555
webpki = { package = "rustls-webpki", version = "0.103.4", default-features = false, optional = true }
5656

57-
5857
[dev-dependencies]
5958
bytes = { version = "1.10.1", default-features = false }
6059
itertools = { version = "0.14.0", default-features = false }
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[build]
2+
target = "riscv32imac-esp-espidf"
3+
4+
[target.riscv32imac-esp-espidf]
5+
linker = "ldproxy"
6+
runner = "espflash flash --monitor"
7+
rustflags = [ "--cfg", "espidf_time64"]
8+
9+
[unstable]
10+
build-std = ["std", "panic_abort"]
11+
12+
[env]
13+
MCU="esp32c6"

validation/esp32-test/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.vscode
2+
/.embuild
3+
/target
4+
/Cargo.lock

validation/esp32-test/Cargo.toml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[package]
2+
name = "esp32-test"
3+
version = "0.1.0"
4+
authors = ["Steve Fan <[email protected]>"]
5+
edition = "2024"
6+
resolver = "2"
7+
rust-version = "1.88.0"
8+
9+
[[bin]]
10+
name = "esp32-test"
11+
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors
12+
13+
[profile.release]
14+
opt-level = "s"
15+
16+
[profile.dev]
17+
debug = true # Symbols are nice and they don't increase the size on Flash
18+
opt-level = "z"
19+
20+
[features]
21+
default = []
22+
23+
experimental = ["esp-idf-svc/experimental"]
24+
25+
[dependencies]
26+
anyhow = { version = "1.0", default-features = false }
27+
esp-idf-svc = "0.51"
28+
log = "0.4"
29+
rustls-rustcrypto = { version = "0.0.2-alpha", path = "../..", default-features = false, features = ["aead-chacha20poly1305", "alloc", "der", "ecdsa-p256", "fast", "kx-p256", "pkcs8", "sign-ecdsa-p256", "tls12", "verify-ecdsa-p256", "verify-ecdsa-p256-sha256"] }
30+
31+
# --- Optional Embassy Integration ---
32+
# esp-idf-svc = { version = "0.51", features = ["critical-section", "embassy-time-driver", "embassy-sync"] }
33+
34+
# If you enable embassy-time-driver, you MUST also add one of:
35+
36+
# a) Standalone Embassy libs ( embassy-time, embassy-sync etc) with a foreign async runtime:
37+
# embassy-time = { version = "0.4.0", features = ["generic-queue-8"] } # NOTE: any generic-queue variant will work
38+
39+
# b) With embassy-executor:
40+
# embassy-executor = { version = "0.7", features = ["executor-thread", "arch-std"] }
41+
42+
# NOTE: if you use embassy-time with embassy-executor you don't need the generic-queue-8 feature
43+
44+
# --- Temporary workaround for embassy-executor < 0.8 ---
45+
# esp-idf-svc = { version = "0.51", features = ["embassy-time-driver", "embassy-sync"] }
46+
# critical-section = { version = "1.1", features = ["std"], default-features = false }
47+
48+
[build-dependencies]
49+
embuild = "0.33"

validation/esp32-test/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
embuild::espidf::sysenv::output();
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "nightly"
3+
components = ["rust-src"]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Rust often needs a bit of an extra main task stack size compared to C (the default is 3K)
2+
CONFIG_ESP_MAIN_TASK_STACK_SIZE=8000
3+
4+
# Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default).
5+
# This allows to use 1 ms granularity for thread sleeps (10 ms by default).
6+
#CONFIG_FREERTOS_HZ=1000
7+
8+
# Workaround for https://github.com/espressif/esp-idf/issues/7631
9+
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n
10+
#CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=n

validation/esp32-test/src/cert.der

389 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)