c# - 在 C# 中使用安全的 websocket

标签 c# asp.net-mvc asp.net-mvc-4 ssl websocket

我正在使用 Fleck在我的 MVC 应用程序中实现 websocket 功能。在本地设置中,我有带有自签名证书的 https 方案,而在生产设置中,我有付费证书。

这是文档中给出的语法。

var server = new WebSocketServer("wss://0.0.0.0:8431");
server.Certificate = new X509Certificate2("MyCert.pfx");
server.Start(socket =>
{
  //...use as normal
}); 

这里不是MyCert.pfx,如果是自签名证书/[辅助证书?它应该是一条路吗?仅提供名称后,它给出错误 System.Security.Cryptography.CryptographicException: The system cannot find the file specified.

最佳答案

是的,参数应该是一个文件路径,你可以将pfx文件放在AppData目录下,并使用Server.MapPath("~/App_Data/MyCert.pfx")

关于c# - 在 C# 中使用安全的 websocket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27371126/

相关文章:

c# - MVC4 + jQuery 淡出通知 div

multithreading - 如何使用 Autofac 从 MVC Controller 创建背景任务?

c# - Web API 可选参数

c# - 为什么我在尝试将大文件发布到 Core Web API 时收到 404

asp.net - 将 ASP.NET MVC 部署到 Windows Server 2003?

c# - 谁在 ASP.Net MVC Pipeline 中先执行?

c# - 如何在WPF应用程序上修复 “The calling thread cannot access this object because a different thread owns it.”

c# - Reflection.Emit 和通用类型

asp.net-mvc - 使用 ASP.NET MVC 作为电子邮件模板引擎 : Good Idea?

asp.net-mvc - 如何使用 .net Framework4.0 在 MVC4 中获取当前 Windows 用户登录名