Skip to content
Draft
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
34 changes: 34 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ jobs:
submodules: true
- name: Run +${{ matrix.target }} on Earthly
run: earthly --ci +${{ matrix.target }}
- name: Extract and display WolfSSL configuration (Linux)
if: matrix.target == 'build-release'
run: |
echo "DEBUG: Listing artifacts directory"
find artifacts/ -name "wolfssl_config.json" -type f 2>/dev/null || echo "DEBUG: No wolfssl_config.json found under artifacts/"
ls -la artifacts/release/ 2>/dev/null | head -20 || echo "DEBUG: artifacts/release/ does not exist"
if [ -f artifacts/release/wolfssl_config.json ]; then
echo "## WolfSSL Build Configuration (Linux)" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY
cat artifacts/release/wolfssl_config.json >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
else
echo "## WolfSSL Build Configuration (Linux)" >> $GITHUB_STEP_SUMMARY
echo "No configuration file found" >> $GITHUB_STEP_SUMMARY
fi
coverage:
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -284,3 +299,22 @@ jobs:
# Only run tests on native architecture (x64/ARM64) since cross-compilation tests won't run
if: matrix.target == 'x86_64-pc-windows-msvc' || matrix.target == 'aarch64-pc-windows-msvc'
run: cargo test --release --target ${{ matrix.target }} -v -v
- name: Extract and display WolfSSL configuration (Windows)
run: |
# Find the wolfssl config JSON file in the target directory
$configFile = Get-ChildItem -Path target -Name "wolfssl_config.json" -Recurse -File | Select-Object -First 1
if ($configFile) {
$configPath = Join-Path "target" $configFile
Write-Host "Found wolfssl config at: $configPath"
$configContent = Get-Content $configPath -Raw
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "## WolfSSL Build Configuration (Windows - ${{ matrix.arch }})"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '```json'
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value $configContent
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value '```'
} else {
Write-Host "No wolfssl config file found"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "## WolfSSL Build Configuration (Windows - ${{ matrix.arch }})"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "No configuration file found"
}
shell: pwsh

10 changes: 9 additions & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ build-dev:
# build-release builds with the Cargo release profile and produces release artifacts
build-release:
FROM +copy-src
DO lib-rust+CARGO --args="build --release" --output="release/[^/]+"
DO lib-rust+CARGO --args="build --release" --output="(release/[^/]+|.*/build/.*/out/wolfssl_config\.json)"

# Copy wolfssl configuration to release directory so it gets saved as an artifact
RUN find target -name "wolfssl_config.json" -type f && \
find target -name "wolfssl_config.json" -type f -exec cp {} target/release/wolfssl_config.json \; && \
echo "Config file copied successfully" && ls -la target/release/wolfssl_config.json || \
echo "WARNING: wolfssl_config.json not found in target"

SAVE ARTIFACT target/release /release AS LOCAL artifacts/release

# run-tests executes all unit and integration tests via Cargo
Expand Down Expand Up @@ -138,6 +145,7 @@ check-dependencies:
FROM +copy-src
DO lib-rust+CARGO --args="deny --all-features check --deny warnings bans license sources"


# publish publishes the target crate to cargo.io. Must specify package by --PACKAGE=<package-name>
publish:
FROM +copy-src
Expand Down
47 changes: 47 additions & 0 deletions wolfssl-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,33 @@ fn build_wolfssl(wolfssl_src: &Path) -> PathBuf {
conf.build()
}

/**
* Export WolfSSL configuration to JSON for CI consumption
*/
fn export_wolfssl_config(config_contents: &str, out_dir: &Path) -> std::io::Result<()> {
use std::io::Write;

// Create a simple JSON structure with just the wolfssl configuration
let config_file_path = out_dir.join("wolfssl_config.json");
let mut config_file = File::create(&config_file_path)?;

// Write the configuration as a simple JSON object
writeln!(config_file, "{{")?;
writeln!(
config_file,
" \"wolfssl_configure_command\": {:?}",
config_contents.trim()
)?;
writeln!(config_file, "}}")?;

println!(
"cargo::warning=WolfSSL config exported to: {}",
config_file_path.display()
);

Ok(())
}

fn main() -> std::io::Result<()> {
// Get the build directory
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
Expand All @@ -570,6 +597,26 @@ fn main() -> std::io::Result<()> {
// Configure and build WolfSSL
let wolfssl_install_dir = build_wolfssl(&wolfssl_src);

// Export config for CI consumption (Unix builds only, Windows uses MSBuild)
if build_target::target_os() != build_target::Os::Windows {
let mut config_path = PathBuf::from(&wolfssl_install_dir);
config_path.push("build/configure.prev");
if let Ok(contents) = fs::read_to_string(config_path) {
println!("cargo::warning=WolfSSL config:{}", contents);
export_wolfssl_config(&contents, &out_dir)?;
}
} else {
// For Windows builds, export the user_settings.h content as config
let settings_path = wolfssl_install_dir.join("wolfssl").join("user_settings.h");
if let Ok(contents) = fs::read_to_string(settings_path) {
println!(
"cargo::warning=WolfSSL Windows config (user_settings.h):{}",
contents
);
export_wolfssl_config(&contents, &out_dir)?;
}
}

// We want to block some macros as they are incorrectly creating duplicate values
// https://github.com/rust-lang/rust-bindgen/issues/687
// TODO: Reach out to tlspuffin and ask if we can incorporate this code and credit them
Expand Down
4 changes: 2 additions & 2 deletions wolfssl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ impl ProtocolVersion {
}

/// Checks if the protocol version is compatible with TLS 1.3
fn is_tls_13(&self) -> bool {
pub fn is_tls_13(&self) -> bool {
matches!(self, Self::TlsV1_3)
}

/// Checks if the protocol version is compatible with DTLS 1.3
fn is_dtls_13(&self) -> bool {
pub fn is_dtls_13(&self) -> bool {
matches!(self, Self::DtlsV1_3)
}
}
Expand Down
Loading