Updated
This commit is contained in:
		@@ -123,7 +123,7 @@ internal class Program
 | 
			
		||||
    private static void StartServer(string serverUri, string certificatePath, string certificatePassword, string requiredPassword)
 | 
			
		||||
    {
 | 
			
		||||
        _server = new WSServer(serverUri);
 | 
			
		||||
        _server.SslConfiguration.Certificate = new X509Certificate2(certificatePath, certificatePassword);
 | 
			
		||||
        _server.SSL.Certificate = new X509Certificate2(certificatePath, certificatePassword);
 | 
			
		||||
        _server.AddEndpoint<WelcomeEndpoint>("/Welcome");
 | 
			
		||||
        _server.Start();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -36,8 +36,7 @@ namespace EonaCat.Network
 | 
			
		||||
        /// <param name="tcpClient">The <see cref="TcpClient"/> associated with the WebSocket connection.</param>
 | 
			
		||||
        /// <param name="protocol">The WebSocket protocol negotiated during the connection.</param>
 | 
			
		||||
        /// <param name="secure">A boolean indicating whether the connection is secure.</param>
 | 
			
		||||
        /// <param name="sslConfig">The SSL configuration for secure connections.</param>
 | 
			
		||||
        /// <param name="logger">The logger for logging.</param>
 | 
			
		||||
        /// <param name="sslConfig">The SSL config for secure connections.</param>
 | 
			
		||||
        internal TcpListenerWSContext(
 | 
			
		||||
          TcpClient tcpClient,
 | 
			
		||||
          string protocol,
 | 
			
		||||
 
 | 
			
		||||
@@ -89,7 +89,7 @@ namespace EonaCat.Network
 | 
			
		||||
        public int Port => _endpoint.Port;
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets the SSL configuration for the secure endpoint.
 | 
			
		||||
        /// Gets the SSL config for the secure endpoint.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public SSLConfigServer SSL { get; }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -77,7 +77,7 @@ namespace EonaCat.Network
 | 
			
		||||
                    endpoint,
 | 
			
		||||
                    pref.IsSecure,
 | 
			
		||||
                    listener.CertificateFolderPath,
 | 
			
		||||
                    listener.SslConfiguration,
 | 
			
		||||
                    listener.SSL,
 | 
			
		||||
                    listener.ReuseAddress
 | 
			
		||||
                  );
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -154,7 +154,7 @@ namespace EonaCat.Network
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public SSLConfigServer SslConfiguration
 | 
			
		||||
        public SSLConfigServer SSL
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
 
 | 
			
		||||
@@ -25,19 +25,19 @@ namespace EonaCat.Network
 | 
			
		||||
            SslProtocols = SslProtocols.Tls12;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public SSLConfigClient(SSLConfigClient configuration)
 | 
			
		||||
        public SSLConfigClient(SSLConfigClient sslConfig)
 | 
			
		||||
        {
 | 
			
		||||
            if (configuration == null)
 | 
			
		||||
            if (sslConfig == null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(configuration));
 | 
			
		||||
                throw new ArgumentNullException(nameof(sslConfig));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            CheckForCertificateRevocation = configuration.CheckForCertificateRevocation;
 | 
			
		||||
            _clientCertSelectionCallback = configuration._clientCertSelectionCallback;
 | 
			
		||||
            _clientCertificates = configuration._clientCertificates;
 | 
			
		||||
            SslProtocols = configuration.SslProtocols;
 | 
			
		||||
            _serverCertValidationCallback = configuration._serverCertValidationCallback;
 | 
			
		||||
            TargetHost = configuration.TargetHost;
 | 
			
		||||
            CheckForCertificateRevocation = sslConfig.CheckForCertificateRevocation;
 | 
			
		||||
            _clientCertSelectionCallback = sslConfig._clientCertSelectionCallback;
 | 
			
		||||
            _clientCertificates = sslConfig._clientCertificates;
 | 
			
		||||
            SslProtocols = sslConfig.SslProtocols;
 | 
			
		||||
            _serverCertValidationCallback = sslConfig._serverCertValidationCallback;
 | 
			
		||||
            TargetHost = sslConfig.TargetHost;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool CheckForCertificateRevocation { get; set; }
 | 
			
		||||
 
 | 
			
		||||
@@ -23,18 +23,18 @@ namespace EonaCat.Network
 | 
			
		||||
            SslProtocols = SslProtocols.Tls12;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public SSLConfigServer(SSLConfigServer configuration)
 | 
			
		||||
        public SSLConfigServer(SSLConfigServer sslConfig)
 | 
			
		||||
        {
 | 
			
		||||
            if (configuration == null)
 | 
			
		||||
            if (sslConfig == null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(configuration));
 | 
			
		||||
                throw new ArgumentNullException(nameof(sslConfig));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            CheckForCertificateRevocation = configuration.CheckForCertificateRevocation;
 | 
			
		||||
            IsClientCertificateRequired = configuration.IsClientCertificateRequired;
 | 
			
		||||
            _clientCertificationValidationCallback = configuration._clientCertificationValidationCallback;
 | 
			
		||||
            SslProtocols = configuration.SslProtocols;
 | 
			
		||||
            Certificate = configuration.Certificate;
 | 
			
		||||
            CheckForCertificateRevocation = sslConfig.CheckForCertificateRevocation;
 | 
			
		||||
            IsClientCertificateRequired = sslConfig.IsClientCertificateRequired;
 | 
			
		||||
            _clientCertificationValidationCallback = sslConfig._clientCertificationValidationCallback;
 | 
			
		||||
            SslProtocols = sslConfig.SslProtocols;
 | 
			
		||||
            Certificate = sslConfig.Certificate;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public bool CheckForCertificateRevocation { get; set; }
 | 
			
		||||
 
 | 
			
		||||
@@ -283,7 +283,7 @@ namespace EonaCat.Network
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public SSLConfigServer SslConfiguration
 | 
			
		||||
        public SSLConfigServer SSL
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
@@ -293,7 +293,7 @@ namespace EonaCat.Network
 | 
			
		||||
                    throw new InvalidOperationException(message);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return _listener.SslConfiguration;
 | 
			
		||||
                return _listener.SSL;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -411,7 +411,7 @@ namespace EonaCat.Network
 | 
			
		||||
        {
 | 
			
		||||
            message = null;
 | 
			
		||||
 | 
			
		||||
            var byUser = _listener.SslConfiguration.Certificate != null;
 | 
			
		||||
            var byUser = _listener.SSL.Certificate != null;
 | 
			
		||||
 | 
			
		||||
            var path = _listener.CertificateFolderPath;
 | 
			
		||||
            var withPort = EndPointListener.CertificateExists(Port, path);
 | 
			
		||||
 
 | 
			
		||||
@@ -253,7 +253,7 @@ namespace EonaCat.Network
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public SSLConfigServer SslConfiguration
 | 
			
		||||
        public SSLConfigServer SSL
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
@@ -263,7 +263,7 @@ namespace EonaCat.Network
 | 
			
		||||
                    throw new InvalidOperationException(message);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                return GetSslConfiguration();
 | 
			
		||||
                return GetSSLConfig();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -366,13 +366,12 @@ namespace EonaCat.Network
 | 
			
		||||
                   || name == _hostname;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private static bool CheckSslConfiguration(
 | 
			
		||||
          SSLConfigServer configuration, out string message
 | 
			
		||||
        private static bool CheckSslConfig(SSLConfigServer sslConfig, out string message
 | 
			
		||||
        )
 | 
			
		||||
        {
 | 
			
		||||
            message = null;
 | 
			
		||||
 | 
			
		||||
            if (configuration.Certificate == null)
 | 
			
		||||
            if (sslConfig.Certificate == null)
 | 
			
		||||
            {
 | 
			
		||||
                message = "There is no server certificate for secure connections.";
 | 
			
		||||
                return false;
 | 
			
		||||
@@ -387,7 +386,7 @@ namespace EonaCat.Network
 | 
			
		||||
            return realm != null && realm.Length > 0 ? realm : _defaultRealm;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private SSLConfigServer GetSslConfiguration()
 | 
			
		||||
        private SSLConfigServer GetSSLConfig()
 | 
			
		||||
        {
 | 
			
		||||
            _sslConfig ??= new SSLConfigServer();
 | 
			
		||||
 | 
			
		||||
@@ -705,9 +704,9 @@ namespace EonaCat.Network
 | 
			
		||||
 | 
			
		||||
            if (IsSecure)
 | 
			
		||||
            {
 | 
			
		||||
                sslConfig = new SSLConfigServer(GetSslConfiguration());
 | 
			
		||||
                sslConfig = new SSLConfigServer(GetSSLConfig());
 | 
			
		||||
 | 
			
		||||
                if (!CheckSslConfiguration(sslConfig, out string message))
 | 
			
		||||
                if (!CheckSslConfig(sslConfig, out string message))
 | 
			
		||||
                {
 | 
			
		||||
                    throw new InvalidOperationException(message);
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@ namespace EonaCat.Network
 | 
			
		||||
    public class FileReader
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Read a configuration file (varName=varValue format #beginning with comments)
 | 
			
		||||
        /// Reads a configuration file (varName=varValue format #beginning with comments)
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <returns>Parameter list.</returns>
 | 
			
		||||
        /// <param name="filePath">File path.</param>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user