Esempio n. 1
0
        internal void InitializeConnection(Socket socket)
        {
            if (!IsDisposed)
            {
                RtmpServerConnection connection = null;
                if (_serverCertificate == null)
                {
                    connection = new RtmpServerConnection(this, new RtmpNetworkStream(socket));
                    if (log.IsDebugEnabled)
                    {
                        log.Debug(__Res.GetString(__Res.Rtmp_SocketListenerAccept, connection.ConnectionId));
                    }
                }
                else
                {
                    SslStream sslStream = new SslStream(new NetworkStream(socket, false), false);
                    //sslStream.AuthenticateAsServer(_serverCertificate, false, SslProtocols.Tls, true);
                    sslStream.AuthenticateAsServer(_serverCertificate, false, SslProtocols.Default, false);
                    connection = new RtmpServerConnection(this, new RtmpNetworkStream(socket, sslStream));
                    if (log.IsDebugEnabled)
                    {
                        log.Debug(__Res.GetString(__Res.Rtmp_SocketListenerAccept, connection.ConnectionId));

                        string msg = string.Format("Cipher: {0} strength {1} Hash: {2} strength {3} Key exchange: {4} strength {5} Protocol: {6} Signed: {7} Encrypted: {8}",
                                                   sslStream.CipherAlgorithm, sslStream.CipherStrength,
                                                   sslStream.HashAlgorithm, sslStream.HashStrength,
                                                   sslStream.KeyExchangeAlgorithm, sslStream.KeyExchangeStrength,
                                                   sslStream.SslProtocol, sslStream.IsSigned, sslStream.IsEncrypted);
                        log.Debug(msg);
                    }
                }

                //We are still in an IOCP thread
                this.AddConnection(connection);
                //FluorineRtmpContext.Initialize(connection);
                _rtmpHandler.ConnectionOpened(connection);
                connection.BeginReceive(true);
            }
        }