Skip to content
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

Custom ServerCertificateValidationCallback [3.1.1] #360

Closed
YetAnotherGeorge opened this issue Mar 16, 2024 · 1 comment
Closed

Custom ServerCertificateValidationCallback [3.1.1] #360

YetAnotherGeorge opened this issue Mar 16, 2024 · 1 comment

Comments

@YetAnotherGeorge
Copy link

Right now our team is using self-signed certificates for testing and socket io for communication.
To use custom certificate validation the solution I've found is:

var socket = new SocketIOClient.SocketIO("https://localhost:8443") {
   HttpClient = new DefaultHttpClient2()
};
socket.ClientWebSocketProvider = () => new DefaultClientWebSocket2();
await socket.ConnectAsync();
// ...

Where DefaultHttpClient2 and ClientWebSocket2 are the exact same classes as their definition on github with the following changes:

public DefaultClientWebSocket2() {
   _ws = new ClientWebSocket();
   _ws.Options.RemoteCertificateValidationCallback = CUSTOM_PREDICATE;
}
 
public DefaultHttpClient2() {
   _handler = new HttpClientHandler();
   _handler.ServerCertificateCustomValidationCallback = CUSTOM_PREDICATE;
   _httpClient = new HttpClient(_handler);
}

This works for version 3.1.1, is there a better way to provide a predicate that will reach both the http client and the web socket client?

@doghappy
Copy link
Owner

doghappy commented Apr 8, 2024

The feature has been done on master, it will be releasing on next version. thanks for the issue.

@doghappy doghappy closed this as completed Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants