From 5c4801fca1d05e15fe5c4118ddcd723a7a48fdb0 Mon Sep 17 00:00:00 2001 From: JacobBarthelmeh Date: Mon, 25 Aug 2025 17:03:10 -0600 Subject: [PATCH] update mono build README instructions and add test case --- .github/workflows/mono.yml | 136 +++++++++++++++++++++++++++++++++++++ wrapper/CSharp/README.md | 7 +- 2 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/mono.yml diff --git a/.github/workflows/mono.yml b/.github/workflows/mono.yml new file mode 100644 index 000000000..d9aa1ba8d --- /dev/null +++ b/.github/workflows/mono.yml @@ -0,0 +1,136 @@ +name: Linux Mono C# Build Test + +# START OF COMMON SECTION +on: + push: + branches: [ 'master', 'main', 'release/**' ] + pull_request: + branches: [ '*' ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +# END OF COMMON SECTION + +jobs: + build_wolfssl: + name: Build wolfSSL C# Wrapper + if: github.repository_owner == 'wolfssl' + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + + # Build wolfSSL using the user_settings.h from the C# wrapper directory + - name: Build wolfSSL + uses: wolfSSL/actions-build-autotools-project@v1 + with: + path: wolfssl + configure: --enable-usersettings CPPFLAGS=-I$GITHUB_WORKSPACE/wolfssl/wrapper/CSharp + install: true + + - name: Install mono-complete + run: | + sudo apt-get update + sudo apt-get install -y mono-complete + + - name: Build and run wolfCrypt test wrapper + working-directory: wolfssl/wrapper/CSharp + env: + LD_LIBRARY_PATH: $GITHUB_WORKSPACE/build-dir/lib + run: | + mcs wolfCrypt-Test/wolfCrypt-Test.cs wolfSSL_CSharp/wolfCrypt.cs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs -OUT:wolfcrypttest.exe + mono wolfcrypttest.exe + + - name: Build wolfSSL client/server test + working-directory: wolfssl/wrapper/CSharp + env: + LD_LIBRARY_PATH: $GITHUB_WORKSPACE/build-dir/lib + run: | + mcs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs -OUT:server.exe + mcs wolfSSL_CSharp/wolfCrypt.cs wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs -OUT:client.exe + + - name: Test wolfSSL client/server communication + working-directory: wolfssl/wrapper/CSharp + env: + LD_LIBRARY_PATH: $GITHUB_WORKSPACE/build-dir/lib + run: | + # Start server in background and capture its PID + timeout 10s mono server.exe > server.log 2>&1 & + SERVER_PID=$! + + # Wait for server to start + sleep 2 + + # Run client and capture output + timeout 5s mono client.exe > client.log 2>&1 + CLIENT_EXIT_CODE=$? + + # Wait a moment for server to process + sleep 1 + + # Kill server + kill $SERVER_PID 2>/dev/null || true + + # Check if client completed successfully (exit code 0) + if [ $CLIENT_EXIT_CODE -eq 0 ]; then + echo "Client completed successfully" + else + echo "Client failed with exit code $CLIENT_EXIT_CODE" + cat client.log + exit 1 + fi + + # Check for success indicators in logs + if grep -q "SSL version is" client.log && grep -q "SSL cipher suite is" client.log; then + echo "TLS handshake successful - SSL version and cipher suite detected" + else + echo "TLS handshake failed - no SSL version/cipher detected" + echo "Client log:" + cat client.log + echo "Server log:" + cat server.log + exit 1 + fi + + - name: Test SNI functionality + working-directory: wolfssl/wrapper/CSharp + env: + LD_LIBRARY_PATH: $GITHUB_WORKSPACE/build-dir/lib + run: | + # Start server with SNI support in background + timeout 10s mono server.exe -S > server_sni.log 2>&1 & + SERVER_PID=$! + + # Wait for server to start + sleep 2 + + # Run client with SNI and capture output + timeout 5s mono client.exe -S localhost > client_sni.log 2>&1 + CLIENT_EXIT_CODE=$? + + # Wait a moment for server to process + sleep 1 + + # Kill server + kill $SERVER_PID 2>/dev/null || true + + # Check if client completed successfully + if [ $CLIENT_EXIT_CODE -eq 0 ]; then + echo "SNI client completed successfully" + else + echo "SNI client failed with exit code $CLIENT_EXIT_CODE" + cat client_sni.log + exit 1 + fi + + # Check for SNI success indicators + if grep -q "SSL version is" client_sni.log && grep -q "SSL cipher suite is" client_sni.log; then + echo "SNI TLS handshake successful" + else + echo "SNI TLS handshake failed" + echo "Client log:" + cat client_sni.log + echo "Server log:" + cat server_sni.log + exit 1 + fi diff --git a/wrapper/CSharp/README.md b/wrapper/CSharp/README.md index 537e6cc9b..ac15e0c33 100644 --- a/wrapper/CSharp/README.md +++ b/wrapper/CSharp/README.md @@ -42,7 +42,8 @@ apt-get install mono-complete ``` ./autogen.sh -./configure --enable-keygen --enable-eccencrypt --enable-ed25519 --enable-curve25519 --enable-aesgcm +cp wrapper/CSharp/user_settings.h . +./configure --enable-usersettings make make check sudo make install @@ -55,7 +56,7 @@ From the `wrapper/CSharp` directory (`cd wrapper/CSharp`): Compile wolfCrypt test: ``` -mcs wolfCrypt-Test/wolfCrypt-Test.cs wolfSSL_CSharp/wolfCrypt.cs -OUT:wolfcrypttest.exe +mcs wolfCrypt-Test/wolfCrypt-Test.cs wolfSSL_CSharp/wolfCrypt.cs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs -OUT:wolfcrypttest.exe mono wolfcrypttest.exe ``` @@ -72,7 +73,7 @@ mcs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs wolfSSL-TLS-Server/wolfSSL- Compile client: ``` -mcs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs -OUT:client.exe +mcs wolfSSL_CSharp/wolfCrypt.cs wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs -OUT:client.exe ``` #### Run the example