public void CreateSSL(AsyncCallback asyncCallback, ListenHandler listen, IServer server) { try { if (server.EnableLog(EventArgs.LogType.Info)) { server.Log(EventArgs.LogType.Info, null, $"{RemoteEndPoint} create ssl stream"); } mBaseNetStream.SSL = true; mSslStream = new SslStreamX(this.SendBufferPool, server.Options.Encoding, server.Options.LittleEndian, mBaseNetStream, false); #if (NETSTANDARD2_0) mSslStream.BeginAuthenticateAsServer(Server.Certificate, new AsyncCallback(asyncCallback), new Tuple <TcpSession, SslStream>(this, this.mSslStream)); #else mSslStream.BeginAuthenticateAsServer(listen.Certificate, false, true, new AsyncCallback(asyncCallback), new Tuple <TcpSession, SslStream>(this, this.mSslStream)); #endif } catch (Exception e_) { if (server.EnableLog(EventArgs.LogType.Warring)) { server.Error(e_, this, "{1} create session ssl error {0}", e_.Message, this.RemoteEndPoint); } this.Dispose(); } }
public ServerOptions AddListen(string host, int port) { ListenHandler listenOptions = new ListenHandler { Host = host, Port = port }; Listens.Add(listenOptions); return(this); }
public ServerOptions AddListenSSL(string certificateFile, string password, string host, int port = 443) { ListenHandler listenOptions = new ListenHandler { Host = host, Port = port, SSL = true, CertificateFile = certificateFile, CertificatePassword = password }; Listens.Add(listenOptions); return(this); }
public ServerOptions AddListenSSL(string certificateFile, string password, SslProtocols?sslProtocols, string host, int port = 443) { ListenHandler listenOptions = new ListenHandler { Host = host, Port = port, SSL = true, CertificateFile = certificateFile, CertificatePassword = password }; if (sslProtocols != null) { listenOptions.SslProtocols = sslProtocols.Value; } Listens.Add(listenOptions); return(this); }