炫意html5
最早CSS3和HTML5移动技术网站之一

c#使用fleck websocket wss访问问题;

本人使用fleck框架用来socket通讯,服务器站点可以通过https访问。
然后前端socket通过ws访问是没问题的,但是使用wss访问就不行了,求解。
后台代码如下:
WebSocketServer server;

            //【含证书】
if (socketType == "wss")
{
server = new WebSocketServer("wss://0.0.0.0:3301");
string certificatePath = ConfigHelper.GetValue("certificatePath");
string password = ConfigHelper.GetValue("password").Trim();
//添加证书(certificatePath:证书路径,password:访问证书数据所需的密码)
server.Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(certificatePath, password);
LogHelper.WriteLog_LocalTxt(server.Certificate.FriendlyName);
//server.Certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(certificatePath, password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.Exportable | System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.MachineKeySet | System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.PersistKeySet);
}
else
{
//【无证书】
//webscoket服务端实例
//server = new WebSocketServer("ws://0.0.0.0:3302");
server = new WebSocketServer("ws://0.0.0.0:3302");
}
//出错后进行重启
server.RestartAfterListenError = true;

回答

客户端是IOS吗,IOS需求必须是Tls1.2

server = new WebSocketServer("wss://0.0.0.0:3301") { 
                RestartAfterListenError = true,
                EnabledSslProtocols = SslProtocols.Tls12,  //IOS要求必须Tls1.2
                Certificate = new X509Certificate2(sslName, sslPassword, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet),
            };

炫意HTML5 » c#使用fleck websocket wss访问问题;

Java基础教程Android基础教程