Skip to content

Commit f8c2e9c

Browse files
authored
Merge pull request #9134 from JacobBarthelmeh/csharp
update mono build README instructions
2 parents d9f8e15 + 7502cba commit f8c2e9c

4 files changed

Lines changed: 150 additions & 4 deletions

File tree

.github/workflows/mono.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Linux Mono C# Build Test
2+
3+
# START OF COMMON SECTION
4+
on:
5+
push:
6+
branches: [ 'master', 'main', 'release/**' ]
7+
pull_request:
8+
branches: [ '*' ]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
# END OF COMMON SECTION
14+
15+
jobs:
16+
build_wolfssl:
17+
name: Build wolfSSL C# Wrapper
18+
if: github.repository_owner == 'wolfssl'
19+
runs-on: ubuntu-24.04
20+
timeout-minutes: 10
21+
steps:
22+
23+
# Build wolfSSL using the user_settings.h from the C# wrapper directory
24+
- name: Build wolfSSL
25+
uses: wolfSSL/actions-build-autotools-project@v1
26+
with:
27+
path: wolfssl
28+
configure: --enable-usersettings CPPFLAGS=-I$GITHUB_WORKSPACE/wolfssl/wrapper/CSharp
29+
install: true
30+
check: false
31+
32+
- name: Install mono-complete
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y mono-complete
36+
37+
- name: Copy wolfSSL.dll to C# wrapper directory
38+
run: |
39+
echo "Copying wolfSSL.dll to C# wrapper directory. $GITHUB_WORKSPACE/build-dir/lib contains:"
40+
ls -la $GITHUB_WORKSPACE/build-dir/lib/*
41+
cp $GITHUB_WORKSPACE/build-dir/lib/libwolfssl.so $GITHUB_WORKSPACE/wolfssl/wrapper/CSharp/wolfssl.dll
42+
cp $GITHUB_WORKSPACE/build-dir/lib/libwolfssl.so $GITHUB_WORKSPACE/wolfssl/wrapper/CSharp/libwolfssl.so
43+
44+
- name: Build and run wolfCrypt test wrapper
45+
working-directory: wolfssl/wrapper/CSharp
46+
run: |
47+
mcs wolfCrypt-Test/wolfCrypt-Test.cs wolfSSL_CSharp/wolfCrypt.cs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs -OUT:wolfcrypttest.exe
48+
mono wolfcrypttest.exe
49+
50+
- name: Build wolfSSL client/server test
51+
working-directory: wolfssl/wrapper/CSharp
52+
env:
53+
LD_LIBRARY_PATH: $GITHUB_WORKSPACE/build-dir/lib
54+
run: |
55+
mcs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs -OUT:server.exe
56+
mcs wolfSSL_CSharp/wolfCrypt.cs wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs -OUT:client.exe
57+
58+
- name: Test wolfSSL client/server communication
59+
working-directory: wolfssl/wrapper/CSharp
60+
env:
61+
LD_LIBRARY_PATH: $GITHUB_WORKSPACE/build-dir/lib
62+
run: |
63+
# Start server in background and capture its PID
64+
timeout 10s mono server.exe > server.log 2>&1 &
65+
SERVER_PID=$!
66+
67+
# Wait for server to start
68+
sleep 2
69+
70+
# Run client and capture output
71+
timeout 5s mono client.exe > client.log 2>&1
72+
CLIENT_EXIT_CODE=$?
73+
74+
# Wait a moment for server to process
75+
sleep 1
76+
77+
# Kill server
78+
kill $SERVER_PID 2>/dev/null || true
79+
80+
# Check if client completed successfully (exit code 0)
81+
if [ $CLIENT_EXIT_CODE -eq 0 ]; then
82+
echo "Client completed successfully"
83+
else
84+
echo "Client failed with exit code $CLIENT_EXIT_CODE"
85+
cat client.log
86+
exit 1
87+
fi
88+
89+
# Check for success indicators in logs
90+
if grep -q "SSL version is" client.log && grep -q "SSL cipher suite is" client.log; then
91+
echo "TLS handshake successful - SSL version and cipher suite detected"
92+
else
93+
echo "TLS handshake failed - no SSL version/cipher detected"
94+
echo "Client log:"
95+
cat client.log
96+
echo "Server log:"
97+
cat server.log
98+
exit 1
99+
fi
100+
101+
- name: Test SNI functionality
102+
working-directory: wolfssl/wrapper/CSharp
103+
env:
104+
LD_LIBRARY_PATH: $GITHUB_WORKSPACE/build-dir/lib
105+
run: |
106+
# Start server with SNI support in background
107+
timeout 10s mono server.exe -S > server_sni.log 2>&1 &
108+
SERVER_PID=$!
109+
110+
# Wait for server to start
111+
sleep 2
112+
113+
# Run client with SNI and capture output
114+
timeout 5s mono client.exe -S localhost > client_sni.log 2>&1
115+
CLIENT_EXIT_CODE=$?
116+
117+
# Wait a moment for server to process
118+
sleep 1
119+
120+
# Kill server
121+
kill $SERVER_PID 2>/dev/null || true
122+
123+
# Check if client completed successfully
124+
if [ $CLIENT_EXIT_CODE -eq 0 ]; then
125+
echo "SNI client completed successfully"
126+
else
127+
echo "SNI client failed with exit code $CLIENT_EXIT_CODE"
128+
cat client_sni.log
129+
exit 1
130+
fi
131+
132+
# Check for SNI success indicators
133+
if grep -q "SSL version is" client_sni.log && grep -q "SSL cipher suite is" client_sni.log; then
134+
echo "SNI TLS handshake successful"
135+
else
136+
echo "SNI TLS handshake failed"
137+
echo "Client log:"
138+
cat client_sni.log
139+
echo "Server log:"
140+
cat server_sni.log
141+
exit 1
142+
fi

tests/api/test_dtls.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ int test_dtls12_basic_connection_id(void)
5050
#ifdef HAVE_AESCCM
5151
"AES128-CCM8",
5252
#endif
53+
#endif /* WOLFSSL_AES_128 && WOLFSSL_STATIC_RSA */
54+
#if defined(WOLFSSL_AES_128)
5355
"DHE-RSA-AES128-SHA256",
5456
"ECDHE-RSA-AES128-SHA256",
5557
#ifdef HAVE_AESGCM
5658
"DHE-RSA-AES128-GCM-SHA256",
5759
"ECDHE-RSA-AES128-GCM-SHA256",
5860
#endif
59-
#endif /* WOLFSSL_AES_128 && WOLFSSL_STATIC_RSA */
61+
#endif /* WOLFSSL_AES_128 */
6062
#endif /* NO_SHA256 */
6163
#endif /* NO_RSA */
6264
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) && !defined(HAVE_FIPS)

wrapper/CSharp/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ apt-get install mono-complete
4242

4343
```
4444
./autogen.sh
45-
./configure --enable-keygen --enable-eccencrypt --enable-ed25519 --enable-curve25519 --enable-aesgcm
45+
cp wrapper/CSharp/user_settings.h .
46+
./configure --enable-usersettings
4647
make
4748
make check
4849
sudo make install
@@ -55,7 +56,7 @@ From the `wrapper/CSharp` directory (`cd wrapper/CSharp`):
5556
Compile wolfCrypt test:
5657

5758
```
58-
mcs wolfCrypt-Test/wolfCrypt-Test.cs wolfSSL_CSharp/wolfCrypt.cs -OUT:wolfcrypttest.exe
59+
mcs wolfCrypt-Test/wolfCrypt-Test.cs wolfSSL_CSharp/wolfCrypt.cs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs -OUT:wolfcrypttest.exe
5960
mono wolfcrypttest.exe
6061
```
6162

@@ -72,7 +73,7 @@ mcs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs wolfSSL-TLS-Server/wolfSSL-
7273
Compile client:
7374

7475
```
75-
mcs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs -OUT:client.exe
76+
mcs wolfSSL_CSharp/wolfCrypt.cs wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs -OUT:client.exe
7677
```
7778

7879
#### Run the example

wrapper/CSharp/user_settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#define WOLFSSL_KEY_GEN /* RSA key gen */
4646
#define WOLFSSL_ASN_TEMPLATE /* default */
4747
#define WOLFSSL_SHA3
48+
#define HAVE_SNI
4849

4950
#if 0
5051
#define OPENSSL_EXTRA

0 commit comments

Comments
 (0)