且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 ClientWebSocket 安全(SSL)连接到 Websocket 服务器

更新时间:2021-12-28 21:41:12

我不完全确定你实际上在问什么,但是...

I am not completely sure about what are you actually asking, but...

如果要为客户端使用自签名证书,则需要使用以下方法手动验证该证书:ServicePointManager.ServerCertificateValidationCallback

If you want to use a self-signed certificate for the client, you need to validate that certificate manually using : ServicePointManager.ServerCertificateValidationCallback

为了测试,你可以这样做:

For the sake of testing, you can do:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

但是在进入生产环境时,您应该删除此代码或输入实际的认证验证代码.

But when moving to production you should remove this code or put an actual certification validation code.