public RtmpServer(RtmpEndpoint endpoint) { _connections = new Hashtable(); _socketListeners = new ArrayList(); _endpoint = endpoint; _rtmpHandler = new RtmpHandler(endpoint); try { if (endpoint.ChannelDefinition.Properties.KeystoreFile != null) { FileSystemResource fsr = new FileSystemResource(endpoint.ChannelDefinition.Properties.KeystoreFile); if (fsr.Exists) { if (endpoint.ChannelDefinition.Properties.KeystorePassword != null) { _serverCertificate = new X509Certificate2(fsr.File.FullName, endpoint.ChannelDefinition.Properties.KeystorePassword); } else { _serverCertificate = X509Certificate.CreateFromCertFile(fsr.File.FullName); } log.Info(string.Format("Certificate issued to {0} and is valid from {1} until {2}.", _serverCertificate.Subject, _serverCertificate.GetEffectiveDateString(), _serverCertificate.GetExpirationDateString())); } else { log.Error("Certificate file not found"); } } else { if (endpoint.ChannelDefinition.Properties.ServerCertificate != null) { StoreName storeName = (StoreName)Enum.Parse(typeof(StoreName), endpoint.ChannelDefinition.Properties.ServerCertificate.StoreName, false); StoreLocation storeLocation = (StoreLocation)Enum.Parse(typeof(StoreLocation), endpoint.ChannelDefinition.Properties.ServerCertificate.StoreLocation, false); X509FindType x509FindType = (X509FindType)Enum.Parse(typeof(X509FindType), endpoint.ChannelDefinition.Properties.ServerCertificate.X509FindType, false); X509Store store = new X509Store(storeName, storeLocation); store.Open(OpenFlags.ReadOnly); X509Certificate2Collection certificateCollection = store.Certificates.Find(x509FindType, endpoint.ChannelDefinition.Properties.ServerCertificate.FindValue, false); X509Certificate2Enumerator enumerator = certificateCollection.GetEnumerator(); if (enumerator.MoveNext()) { _serverCertificate = enumerator.Current; log.Info(string.Format("Certificate issued to {0} and is valid from {1} until {2}.", _serverCertificate.Subject, _serverCertificate.GetEffectiveDateString(), _serverCertificate.GetExpirationDateString())); } else { log.Error("Certificate not found"); } } } } catch (Exception ex) { log.Error("Error loading certificate.", ex); } }
public override void Push(IMessage message, IMessageClient messageClient) { _lock.AcquireReaderLock(); try { if (IsClosed || IsClosing || IsDisconnecting) { return; // Already shutting down. } } finally { _lock.ReleaseReaderLock(); } RtmpHandler.Push(this, message, messageClient); }
public RtmpServer(RtmpEndpoint endpoint) { _connections = new Hashtable(); _socketListeners = new ArrayList(); _endpoint = endpoint; _rtmpHandler = new RtmpHandler(endpoint); try { if (endpoint.ChannelDefinition.Properties.KeystoreFile != null) { FileSystemResource fsr = new FileSystemResource(endpoint.ChannelDefinition.Properties.KeystoreFile); if (fsr.Exists) { if (endpoint.ChannelDefinition.Properties.KeystorePassword != null) _serverCertificate = new X509Certificate2(fsr.File.FullName, endpoint.ChannelDefinition.Properties.KeystorePassword); else _serverCertificate = X509Certificate.CreateFromCertFile(fsr.File.FullName); log.Info(string.Format("Certificate issued to {0} and is valid from {1} until {2}.", _serverCertificate.Subject, _serverCertificate.GetEffectiveDateString(), _serverCertificate.GetExpirationDateString())); } else log.Error("Certificate file not found"); } else { if (endpoint.ChannelDefinition.Properties.ServerCertificate != null) { StoreName storeName = (StoreName)Enum.Parse(typeof(StoreName), endpoint.ChannelDefinition.Properties.ServerCertificate.StoreName, false); StoreLocation storeLocation = (StoreLocation)Enum.Parse(typeof(StoreLocation), endpoint.ChannelDefinition.Properties.ServerCertificate.StoreLocation, false); X509FindType x509FindType = (X509FindType)Enum.Parse(typeof(X509FindType), endpoint.ChannelDefinition.Properties.ServerCertificate.X509FindType, false); X509Store store = new X509Store(storeName, storeLocation); store.Open(OpenFlags.ReadOnly); X509Certificate2Collection certificateCollection = store.Certificates.Find(x509FindType, endpoint.ChannelDefinition.Properties.ServerCertificate.FindValue, false); X509Certificate2Enumerator enumerator = certificateCollection.GetEnumerator(); if (enumerator.MoveNext()) { _serverCertificate = enumerator.Current; log.Info(string.Format("Certificate issued to {0} and is valid from {1} until {2}.", _serverCertificate.Subject, _serverCertificate.GetEffectiveDateString(), _serverCertificate.GetExpirationDateString())); } else log.Error("Certificate not found"); } } } catch (Exception ex) { log.Error("Error loading certificate.", ex); } }
public RtmptServer(RtmptEndpoint endpoint) { _connections = new SynchronizedHashtable(); _endpoint = endpoint; _rtmpHandler = new RtmpHandler(endpoint); }