mikerochip / unity-websocket

Easy-to-use WebSocket MonoBehaviour for Unity. NativeWebSocket alternative.
Other
36 stars 5 forks source link

Investigate adding config to disable SSL validation #7

Open mikerochip opened 1 year ago

mikerochip commented 1 year ago

Mono has a bug where no ssl validation callbacks are called for WebSockets.

References:

May need to replace usage of ClientWebSocket with a vendored copy of websocket-sharp

Maybe not possible for WebGL / pure JavaScript:

mikerochip commented 1 year ago

Using websocket-sharp works for non-WebGL to bypass the mono bug where cert validation callbacks are not properly called. Experimental branch here.

There is no great workaround for JavaScript outside of using a Node websocket library with rejectUnauthorized: true.

This library may become become bloated with the inclusion of these two things. Will have to ponder this more.

tmaxted commented 6 months ago

Hi there, apologies for reviving this after almost a year!

Thank you very much for the references, they were very helpful. I had this exact situation but actually managed to fix it by setting a custom ServicePointManager CertificatePolicy. See gist for code snippets.

Hope this helps!

mikerochip commented 6 months ago

No need to apologize! I wish WebGL had a decent path to a solution, but at least with the technique you discovered I won't have to vendor websocket-sharp for the DotNet path. I really appreciate it, thank you!