C
C#8mo ago
mynarco

Cannot find RemoteCertificateValidationCallback in ClientWebSocketOptions

Hello i am trying to bypass ssl certs by setting RemoteCertificateValidationCallback in the websocket options but they dont exist?
Socket = new ClientWebSocket();
Socket.Options.RemoteCertificateValidationCallback = delegate { return true; };
Socket = new ClientWebSocket();
Socket.Options.RemoteCertificateValidationCallback = delegate { return true; };
error:
'ClientWebSocketOptions' does not contain a definition for 'RemoteCertificateValidationCallback' and no accessible extension method 'RemoteCertificateValidationCallback' accepting a first argument of type 'ClientWebSocketOptions' could be found (are you missing a using directive or an assembly reference?)
'ClientWebSocketOptions' does not contain a definition for 'RemoteCertificateValidationCallback' and no accessible extension method 'RemoteCertificateValidationCallback' accepting a first argument of type 'ClientWebSocketOptions' could be found (are you missing a using directive or an assembly reference?)
msdn article: https://learn.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocketoptions.remotecertificatevalidationcallback?view=net-8.0#system-net-websockets-clientwebsocketoptions-remotecertificatevalidationcallback
ClientWebSocketOptions.RemoteCertificateValidationCallback Property...
Gets or sets the callback to validate a server certificate.
21 Replies
reflectronic
reflectronic8mo ago
yes, it says it is only available in .NET Core you are probably using .NET Framework
mynarco
mynarcoOP8mo ago
ah duh, sorry. do you think there is any way to bypass certs on clientwebsocket then without that?
reflectronic
reflectronic8mo ago
yes hold try setting ServicePointManager.ServerCertificateValidationCallback
mynarco
mynarcoOP8mo ago
yup i have already set that
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
still not workign thourhg
reflectronic
reflectronic8mo ago
presumably you are getting an exception because the validation fails what is the exception, and what is the call stack
mynarco
mynarcoOP8mo ago
yes, i have noticed the two problems i am getting are the fact that - when i set the scheme to wsit returns Unable to connect to remote server - when i use wss it returns the ssl verification error 1sec
mynarco
mynarcoOP8mo ago
mynarco
mynarcoOP8mo ago
this is when i use the ws scheme
mynarco
mynarcoOP8mo ago
mynarco
mynarcoOP8mo ago
this is the server i am attempting to connect to
http://841b7dc6c971f26765c2dacc7a326ae6.loophole.site/
http://841b7dc6c971f26765c2dacc7a326ae6.loophole.site/
which is up
reflectronic
reflectronic8mo ago
ah. i guess you are using xamarin. hm
mynarco
mynarcoOP8mo ago
hm? what is xamarin?
reflectronic
reflectronic8mo ago
hm. well. maybe not
mynarco
mynarcoOP8mo ago
this server is written in python using sockets(because im lazy :p)
reflectronic
reflectronic8mo ago
is it unity? what are you using to write this
mynarco
mynarcoOP8mo ago
godot but i am using c#'s web library to handle web stuff
reflectronic
reflectronic8mo ago
well, uh, i would suggest updating to a newer version of godot, which would let you use RemoteCertificateValidationCallback
mynarco
mynarcoOP8mo ago
unfortunately that isnt possible :(
mynarco
mynarcoOP8mo ago
the games codebase is already established and migrating from godot 3.5 to godot 4 is equivalent to rewriting the entire game. here is the codebase https://github.com/anthony-63/FluxV2
GitHub
GitHub - anthony-63/FluxV2: FluxV2, rhythm game written in godot. O...
FluxV2, rhythm game written in godot. Originally written by kermeet, and continued by me. - anthony-63/FluxV2
reflectronic
reflectronic8mo ago
can you try
ServicePointManager.CertificatePolicy = new NullCertificatePolicy();

class NullCertificatePolicy : ICertificatePolicy
{
public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
=> true;
}
ServicePointManager.CertificatePolicy = new NullCertificatePolicy();

class NullCertificatePolicy : ICertificatePolicy
{
public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
=> true;
}
this seems to be a known issue https://github.com/mono/mono/issues/8660
mynarco
mynarcoOP8mo ago
yes it has worked thank you!
Want results from more Discord servers?
Add your server