Skip to content

Commit 5d0b7e0

Browse files
committed
updated readme & sni function
1 parent b2e7707 commit 5d0b7e0

3 files changed

Lines changed: 47 additions & 28 deletions

File tree

wrapper/CSharp/README.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ apt-get upgrade
3030
apt-get install mono-complete
3131
```
3232

33-
# Build wolfSSL and install
33+
### Build wolfSSL and install
3434

3535
```
3636
./autogen.sh
@@ -40,24 +40,42 @@ make check
4040
sudo make install
4141
```
4242

43-
# Build and run the wrapper
43+
### Build and run the wrapper
4444

4545
```
4646
cd wrapper/CSharp
47+
```
48+
49+
Building the server:
50+
```
51+
mcs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs \
52+
wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs && \
53+
cp wolfSSL_CSharp/wolfSSL.exe ../../certs/server.exe
54+
```
4755

56+
Building the client:
57+
```
4858
mcs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs \
49-
wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs
59+
wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs && \
60+
cp wolfSSL_CSharp/wolfSSL.exe ../../certs/client.exe
5061
```
5162

52-
# Run the example
63+
### Run the example
5364

65+
In one terminal instance run:
5466
```
55-
cp wolfSSL_CSharp/wolfSSL.exe ../../certs
5667
cd ../../certs
57-
mono wolfSSL.exe
68+
mono server.exe
69+
```
70+
71+
And in another terminal instance run:
72+
```
73+
cd ../../certs
74+
mono client.exe
75+
```
5876

59-
Calling ctx Init from wolfSSL
60-
Finished init of ctx .... now load in cert and key
61-
Ciphers : TLS13-AES128-GCM-SHA256:TLS13-AES256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305-OLD:ECDHE-ECDSA-CHACHA20-POLY1305-OLD:DHE-RSA-CHACHA20-POLY1305-OLD
62-
Started TCP and waiting for a connection
77+
### Enabling SNI
78+
To enable SNI, just pass the `-S` argument with the specified hostname:
79+
```
80+
mono client.exe -S hostname
6381
```

wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,21 @@ private static int myVerify(int preverify, IntPtr x509_ctx)
6565
/// wolfSSL.
6666
/// <param name="args">Parameters passed via command line</param>
6767
/// </summary>
68-
private static bool haveSNI(string[] args)
68+
private static bool haveSNI(string[] args)
6969
{
70-
if (args != null && args.Length == 2 && args[0] == "-S")
71-
{
72-
Console.WriteLine("SNI IS: ON");
73-
return true;
74-
}
75-
else {
76-
Console.WriteLine("SNI IS: OFF");
77-
return false;
70+
bool sniON = false;
71+
for (int i = 0; i < args.Length; i++) {
72+
if (args[i] == "-S") {
73+
sniON = true;
74+
break;
75+
}
7876
}
77+
Console.WriteLine("SNI IS: " + sniON);
78+
return sniON;
7979
}
8080

8181

82+
8283
public static void Main(string[] args)
8384
{
8485
IntPtr ctx;

wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ private static void clean(IntPtr ssl, IntPtr ctx)
5353
/// wolfSSL.
5454
/// <param name="args">Parameters passed via command line</param>
5555
/// </summary>
56-
private static bool haveSNI(string[] args)
56+
private static bool haveSNI(string[] args)
5757
{
58-
if (args != null && args.Length == 2 && args[0] == "-S")
59-
{
60-
Console.WriteLine("SNI IS: ON");
61-
return true;
62-
}
63-
else {
64-
Console.WriteLine("SNI IS: OFF");
65-
return false;
58+
bool sniON = false;
59+
for (int i = 0; i < args.Length; i++) {
60+
if (args[i] == "-S") {
61+
sniON = true;
62+
break;
63+
}
6664
}
65+
Console.WriteLine("SNI IS: " + sniON);
66+
return sniON;
6767
}
6868

6969
/// <summary>

0 commit comments

Comments
 (0)