使用 ClientWebSocket 安全(SSL)连接到 Websocket 服务器 [英] Using ClientWebSocket for Secured(SSL) connection to Websocket server

查看:139
本文介绍了使用 ClientWebSocket 安全(SSL)连接到 Websocket 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在 .Net 中搜索支持 SSL(和代理)的回显客户端的示例代码,我有不支持 SSL 和代理的简单回显客户端,但我需要使用证书实现 SSL 的客户端(自签名)

I tried to do googling for example code for echo client which supports SSL (and proxy) in .Net, i have simple echo client which does not support SSL and Proxy, but i need client which has got SSL implementation with Certificates (Self Signed)

我使用 ClientWebSocket 进行连接(Websocket 服务器在 java 中).

I am using ClientWebSocket for connection (Websocket Server is in java).

如何在 websocket 客户端 (.net) 和服务器 (java) 之间共享相同的自签名证书?

How to share same self-signed certificate between websocket client(.net) and server (java) ?

我试图找到一些例子但没有得到任何指导,任何方向都会有很大帮助.

I am trying to find some example but not getting anyhting, any direction would be a great help.

推荐答案

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

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.

这篇关于使用 ClientWebSocket 安全(SSL)连接到 Websocket 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆