我正在使用 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/