简体   繁体   中英

WebSocket Certificate on Mono (Mac, C#)

I am trying to create some sort of Push manager, client side, that will listen to what the server has to say.

Nothing hard so... I have written it PC side, thanks to WebSocket4Net, on C#, and it works perfectly.

But here is the issue...: my application has to work on Mac too, using the same code. I use Mono obviously, and the WebSocket4Net lib works. Unfortunately, every time I try to open a socket, I have a nice " RemoteCertificateNotAvailable ", followed by a " Invalid certificate received from server ".

Here is what I have tried, following some advices from the web:

webSocket.AllowUntrustedCertificate = true;
System.Net.ServicePointManager.ServerCertificateValidationCallback = callbackValidation;

The code is basic and looks like the one on the web site of the lib: https://websocket4net.codeplex.com

I don't know why these solutions do not work. Other posts say this should work, and I have no idea why it doesn't here.

It CAN work by manually adding trusted certificates to Mono (mozroots --import --sync), or with certmgr, or something like that. But I don't want this solution, as it needs to work on any other computer than mine without installing anything. I can accept running some command in my application that will install some certificates... Let's say I am interested in these solutions. But I would rather find a solution implying some lines of C# code.

So... Does anyone have an idea on how to bypass this problem?

Okay the creator of the WebSocket4Net lib did a fix in august for that actually. System.Net.ServicePointManager.ServerCertificateValidationCallback works now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM