Files
wolfssl/wrapper/CSharp/README.md
T

105 lines
2.3 KiB
Markdown
Raw Normal View History

2023-01-16 11:13:25 -08:00
# wolfSSL CSharp Wrappers
This directory contains the CSharp wrapper for the wolfSSL TLS layer with examples.
2024-09-24 14:29:46 -07:00
* `wolfSSL_CSharp`: wolfSSL TLS layer wrappers (library).
* `wolfCrypt-Test`: wolfCrypt layer wrapper testing.
* `user_settings.h`: wolfCrypt wrapper user settings.
2023-01-16 11:13:25 -08:00
Examples:
* `wolfSSL-DTLS-PSK-Server`
* `wolfSSL-DTLS-Server`
* `wolfSSL-Example-IOCallbacks`
* `wolfSSL-TLS-Client`
* `wolfSSL-TLS-PSK-Client`
* `wolfSSL-TLS-PSK-Server`
* `wolfSSL-TLS-Server`
* `wolfSSL-TLS-ServerThreaded`
## Windows
A Visual Studio solution `wolfSSL_CSharp.sln` is provided. This will allow you
to build the wrapper library and examples. It includes the wolfSSL Visual Studio
project directly.
2024-09-24 14:29:46 -07:00
To successfully run and build the solution on Windows Visual Studio you will
need to open a new solution `wolfSSL_CSharp.sln` located in `wrapper\CSharp\wolfSSL_CSharp.sln`.
Select the CPU type, configuration, and target file.
select `Build` and either `Rebuild Solution` or `Build Solution`.
2024-05-30 15:41:01 +02:00
## Linux (Ubuntu) using mono
2023-01-16 11:13:25 -08:00
Prerequisites for linux:
```
2024-05-30 15:41:01 +02:00
apt-get update
apt-get upgrade
apt-get install mono-complete
2023-01-16 11:13:25 -08:00
```
2024-06-04 17:54:21 +02:00
### Build wolfSSL and install
2023-01-16 11:13:25 -08:00
```
./autogen.sh
2024-09-24 14:29:46 -07:00
./configure --enable-keygen --enable-eccencrypt --enable-ed25519 --enable-curve25519 --enable-aesgcm
2023-01-16 11:13:25 -08:00
make
make check
sudo make install
```
2024-09-24 14:29:46 -07:00
### Build and run the wolfCrypt test wrapper
2023-01-16 11:13:25 -08:00
2024-09-24 14:29:46 -07:00
From the `wrapper/CSharp` directory (`cd wrapper/CSharp`):
Compile wolfCrypt test:
2023-01-16 11:13:25 -08:00
```
2024-09-24 14:29:46 -07:00
mcs wolfCrypt-Test/wolfCrypt-Test.cs wolfSSL_CSharp/wolfCrypt.cs -OUT:wolfcrypttest.exe
mono wolfcrypttest.exe
2024-06-04 17:54:21 +02:00
```
2023-01-16 11:13:25 -08:00
2024-09-24 14:29:46 -07:00
### Build and run the wolfSSL client/server test
From the `wrapper/CSharp` directory (`cd wrapper/CSharp`):
Compile server:
2024-06-04 17:54:21 +02:00
```
2024-09-24 14:29:46 -07:00
mcs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs -OUT:server.exe
2024-05-30 15:41:01 +02:00
```
2023-01-16 11:13:25 -08:00
Compile client:
2024-06-04 17:54:21 +02:00
```
2024-09-24 14:29:46 -07:00
mcs wolfSSL_CSharp/wolfSSL.cs wolfSSL_CSharp/X509.cs wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs -OUT:client.exe
2024-06-04 17:54:21 +02:00
```
2023-01-16 11:13:25 -08:00
2024-09-24 14:29:46 -07:00
#### Run the example
2024-06-04 17:54:21 +02:00
In one terminal instance run the server:
2023-01-16 11:13:25 -08:00
```
2024-06-04 17:54:21 +02:00
mono server.exe
```
2023-01-16 11:13:25 -08:00
And in another terminal instance run the client:
2024-06-04 17:54:21 +02:00
```
mono client.exe
```
2024-09-24 14:29:46 -07:00
#### Enabling SNI
2024-06-04 23:08:56 +02:00
To enable SNI, just pass the `-S` argument with the specified hostname to the client:
2024-06-04 17:54:21 +02:00
```
mono client.exe -S hostname
2023-01-16 11:13:25 -08:00
```
2024-06-04 23:08:56 +02:00
And run the server with the `-S` flag:
```
mono server.exe -S
```