diff --git a/.github/workflows/mono.yml b/.github/workflows/mono.yml new file mode 100644 index 000000000..5b76095d7 --- /dev/null +++ b/.github/workflows/mono.yml @@ -0,0 +1,142 @@ +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 + check: false + + - name: Install mono-complete + run: | + sudo apt-get update + sudo apt-get install -y mono-complete + + - name: Copy wolfSSL.dll to C# wrapper directory + run: | + echo "Copying wolfSSL.dll to C# wrapper directory. $GITHUB_WORKSPACE/build-dir/lib contains:" + ls -la $GITHUB_WORKSPACE/build-dir/lib/* + cp $GITHUB_WORKSPACE/build-dir/lib/libwolfssl.so $GITHUB_WORKSPACE/wolfssl/wrapper/CSharp/wolfssl.dll + cp $GITHUB_WORKSPACE/build-dir/lib/libwolfssl.so $GITHUB_WORKSPACE/wolfssl/wrapper/CSharp/libwolfssl.so + + - name: Build and run wolfCrypt test wrapper + working-directory: wolfssl/wrapper/CSharp + 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/tests/api/test_dtls.c b/tests/api/test_dtls.c index 04140d807..8edebe4ca 100644 --- a/tests/api/test_dtls.c +++ b/tests/api/test_dtls.c @@ -50,13 +50,15 @@ int test_dtls12_basic_connection_id(void) #ifdef HAVE_AESCCM "AES128-CCM8", #endif +#endif /* WOLFSSL_AES_128 && WOLFSSL_STATIC_RSA */ +#if defined(WOLFSSL_AES_128) "DHE-RSA-AES128-SHA256", "ECDHE-RSA-AES128-SHA256", #ifdef HAVE_AESGCM "DHE-RSA-AES128-GCM-SHA256", "ECDHE-RSA-AES128-GCM-SHA256", #endif -#endif /* WOLFSSL_AES_128 && WOLFSSL_STATIC_RSA */ +#endif /* WOLFSSL_AES_128 */ #endif /* NO_SHA256 */ #endif /* NO_RSA */ #if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) && !defined(HAVE_FIPS) 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 diff --git a/wrapper/CSharp/user_settings.h b/wrapper/CSharp/user_settings.h index 21a72a69b..ce37a599d 100644 --- a/wrapper/CSharp/user_settings.h +++ b/wrapper/CSharp/user_settings.h @@ -45,6 +45,7 @@ #define WOLFSSL_KEY_GEN /* RSA key gen */ #define WOLFSSL_ASN_TEMPLATE /* default */ #define WOLFSSL_SHA3 +#define HAVE_SNI #if 0 #define OPENSSL_EXTRA