c# - 通过 SSL 连接身份验证问题的安全 Websocket C#
问题描述
我正在使用 X509Certificate2 类和 sslStream 开发安全的 WebSocket 实现。在调用AuthenticateAsServer时,它会在已通过身份验证的安全上下文和客户端上给出不允许此操作的错误,我在 WebSocket 握手期间收到错误错误:net:: ERR_SSL_PROTOCOL_ERROR。下面是我的服务器实现代码:
加载证书:
serverCertificate = X509Certificate.CreateFromCertFile("Certificate.cer");
身份验证:此行出现错误sslStream.AuthenticateAsServer(serverCertificate, false, System.Security.Authentication.SslProtocols.Tls12, false);
如果上面的AuthenticateAsServer方法被删除,那么下面一行需要验证错误:
await sslStream.ReadAsync(buffer, 0, buffer.Length, cts.Token);
解决方案
推荐阅读
- neo4j - 在 cypher Neo4j 中处理嵌套的可选数据
- sql - oracle如何将各行的数据显示到一列?
- c - stdint.h include_next'd from stdint.h not found
- javascript - 如何防止表单提交,执行一些 JavaScript,然后在将数据传递到 NODE 时运行表单?
- angular - ngClass 最初不应用 css 类,仅在单击后
- firebase-cloud-messaging - FCM 到单个设备的最大消息速率
- c# - 参数 1:无法从 'System.Timespan' 转换为 'Instasharper.Classes.IRequestDelay'
- python - “它是如何找到 libpython 的?!” 谜
- c++ - 为函数 PlaySound 使用字符串变量
- c# - 如何将 SQL 查询转换为 LINQ