-
Notifications
You must be signed in to change notification settings - Fork 836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSharp Wrapper SNI Support #7610
Conversation
@@ -417,6 +459,8 @@ public void free() | |||
|
|||
public static readonly int SUCCESS = 1; | |||
public static readonly int FAILURE = 0; | |||
public static readonly int WOLFSSL_SNI_HOST_NAME = 0; | |||
public static readonly int WOLFSSL_SNI_HOST_NAME_OUTER = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please remove WOLFSSL_SNI_HOST_NAME_OUTER
here and also in ssl.h. I cannot find any place it is used and its a duplicate value in the enum, which is odd.
… got lost during editing)
… the name client side via -S flag
/// </summary> | ||
private static bool haveSNI(string[] args) | ||
{ | ||
if (args != null && args.Length == 2 && args[0] == "-S") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this working for you? mono wolfSSL.exe -S
shows SNI IS: OFF
wrapper/CSharp/README.md
Outdated
``` | ||
|
||
Build wolfSSL and install: | ||
# Build wolfSSL and install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make ###
for right heading.
wrapper/CSharp/README.md
Outdated
@@ -38,21 +40,21 @@ make check | |||
sudo make install | |||
``` | |||
|
|||
Build and run the wrapper: | |||
# Build and run the wrapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make ###
for right heading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also show building the client with mono and add SNI example / docs?
wrapper/CSharp/README.md
Outdated
|
||
Run the example: | ||
# Run the example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make ###
for right heading.
- removed tlsext callback (since it's a compatibility one) - updated testing examples and wrapper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work. Very close to complete!
@@ -3811,7 +3811,6 @@ WOLFSSL_API void* wolfSSL_CTX_GetHeap(WOLFSSL_CTX* ctx, WOLFSSL* ssl); | |||
/* SNI types */ | |||
enum { | |||
WOLFSSL_SNI_HOST_NAME = 0, | |||
WOLFSSL_SNI_HOST_NAME_OUTER = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This was an artifact from an early ECH that was later changed and this was left behind and should be removed.
@@ -20224,6 +20206,27 @@ void wolfSSL_THREADID_set_numeric(void* id, unsigned long val) | |||
* HAVE_LIGHTY || WOLFSSL_HAPROXY || WOLFSSL_OPENSSH || | |||
* HAVE_SBLIM_SFCB)) */ | |||
|
|||
#ifdef HAVE_SNI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Moved these outside of the strict compatibility layer macros and made accessible to match the WOLFSSL_CTX member of HAVE_SNI only.
wrapper/CSharp/README.md
Outdated
|
||
### Enabling SNI | ||
|
||
To enable SNI, just pass the `-S` argument with the specified hostname: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The server.exe also needs run with -S
to work. Please add that to the steps.
/// wolfSSL. | ||
/// <param name="args">Parameters passed via command line</param> | ||
/// </summary> | ||
private static bool haveSNI(string[] args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have this function return int
with the index for the i+1
instead of bool
, so you don't have to hard code args[1].Trim();
below. Use -1 to indicate not found.
return; | ||
} | ||
|
||
if (haveSNI(args)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to:
int sniArg = haveSNI(args);
if (sniArg >= 0) {
string sniHostNameString = args[sniArg].Trim();
string fileCert = @"server-cert.pem"; | ||
string fileKey = @"server-key.pem"; | ||
string fileCert = @"../../certs/server-cert.pem"; | ||
string fileKey = @"../../certs/server-key.pem"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change has implications on the Windows VS build:
PS D:\work\sni-wrappers\wrapper\CSharp\DLL Debug\Win32> .\wolfSSL-TLS-Server.exe
Calling ctx Init from wolfSSL
Finished init of ctx .... now load in cert and key
Could not find cert or key file
freeing ctx handle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might consider logic like wolfssl/test.h ChangeToWolfRoot or gate the path based on _WIN32
...
…icates; - Updated all the examples with it;
@@ -87,6 +121,12 @@ public static void Main(string[] args) | |||
return; | |||
} | |||
|
|||
if (!File.Exists(dhparam.ToString())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this on Visual Studio 2022. Got this error:
The name 'dhparam' does not exist in the current context
wolfSSL-TLS-Server
C:\Users\David Garske\Documents\wolfssl\wrapper\CSharp\wolfSSL-TLS-Server\wolfSSL-TLS-Server.cs
124
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on Windows and Linux. Thanks Reda. @JacobBarthelmeh will you give it a final?
CSharp Wrapper SNI Support
Description
Fixes zd#17990
Checklist