Пример #1
0
        /// <summary>
        /// handle other socket options like TCP_NO_DELAY here
        /// </summary>
        /// <param name="settings"></param>
        protected override void OnConfigure(SessionSettings settings)
        {
            try
            {
                reconnectInterval_ = Convert.ToInt32(settings.Get().GetLong(SessionSettings.RECONNECT_INTERVAL));
            }
            catch (System.Exception)
            { }

            // Don't know if this is required in order to handle settings in the general section
            socketSettings_.Configure(settings.Get());
        }
Пример #2
0
        private SocketSettings CreateWithSslConfig(bool sslValidateCertificates, bool sslCheckCertificateRevocation)
        {
            var dict = BaseTestDict();

            dict.SetBool(SessionSettings.SSL_VALIDATE_CERTIFICATES, sslValidateCertificates);
            dict.SetBool(SessionSettings.SSL_CHECK_CERTIFICATE_REVOCATION, sslCheckCertificateRevocation);
            SocketSettings socketSettings = new SocketSettings();

            socketSettings.Configure(dict);
            return(socketSettings);
        }
Пример #3
0
        public void Configure()
        {
            SocketSettings socketSettings = new SocketSettings();

            socketSettings.Configure(BaseTestDict());

            Assert.IsFalse(socketSettings.SocketNodelay);
            Assert.AreEqual(1, socketSettings.SocketReceiveBufferSize);
            Assert.AreEqual(2, socketSettings.SocketSendBufferSize);
            Assert.AreEqual(3, socketSettings.SocketReceiveTimeout);
            Assert.AreEqual(4, socketSettings.SocketSendTimeout);
            Assert.AreEqual("SSL_SERVERNAME", socketSettings.ServerCommonName);
            Assert.IsFalse(socketSettings.ValidateCertificates);
            Assert.AreEqual("SSL_CERTIFICATE", socketSettings.CertificatePath);
            Assert.AreEqual("SSL_CA_CERTIFICATE", socketSettings.CACertificatePath);
            Assert.AreEqual("SSL_CERTIFICATE_PASSWORD", socketSettings.CertificatePassword);
            Assert.AreEqual(SslProtocols.Tls12, socketSettings.SslProtocol);
            Assert.IsFalse(socketSettings.CheckCertificateRevocation);
            Assert.IsTrue(socketSettings.UseSSL);
            Assert.IsFalse(socketSettings.RequireClientCertificate);
        }
Пример #4
0
        public void TestSocketSettingsConfigure()
        {
            Dictionary dict = new Dictionary();

            dict.SetBool(SessionSettings.SOCKET_NODELAY, false);
            dict.SetLong(SessionSettings.SOCKET_RECEIVE_BUFFER_SIZE, 1);
            dict.SetLong(SessionSettings.SOCKET_SEND_BUFFER_SIZE, 2);
            dict.SetLong(SessionSettings.SOCKET_RECEIVE_TIMEOUT, 3);
            dict.SetLong(SessionSettings.SOCKET_SEND_TIMEOUT, 4);
            dict.SetString(SessionSettings.SSL_SERVERNAME, "SSL_SERVERNAME");
            dict.SetBool(SessionSettings.SSL_VALIDATE_CERTIFICATES, false);
            dict.SetString(SessionSettings.SSL_CERTIFICATE, "SSL_CERTIFICATE");
            dict.SetString(SessionSettings.SSL_CA_CERTIFICATE, "SSL_CA_CERTIFICATE");
            dict.SetString(SessionSettings.SSL_CERTIFICATE_PASSWORD, "SSL_CERTIFICATE_PASSWORD");
            dict.SetString(SessionSettings.SSL_PROTOCOLS, "Tls12");
            dict.SetBool(SessionSettings.SSL_CHECK_CERTIFICATE_REVOCATION, false);
            dict.SetBool(SessionSettings.SSL_ENABLE, true);
            dict.SetBool(SessionSettings.SSL_REQUIRE_CLIENT_CERTIFICATE, false);

            SocketSettings socketSettings = new SocketSettings();

            socketSettings.Configure(dict);

            Assert.IsFalse(socketSettings.SocketNodelay);
            Assert.AreEqual(1, socketSettings.SocketReceiveBufferSize);
            Assert.AreEqual(2, socketSettings.SocketSendBufferSize);
            Assert.AreEqual(3, socketSettings.SocketReceiveTimeout);
            Assert.AreEqual(4, socketSettings.SocketSendTimeout);
            Assert.AreEqual("SSL_SERVERNAME", socketSettings.ServerCommonName);
            Assert.IsFalse(socketSettings.ValidateCertificates);
            Assert.AreEqual("SSL_CERTIFICATE", socketSettings.CertificatePath);
            Assert.AreEqual("SSL_CA_CERTIFICATE", socketSettings.CACertificatePath);
            Assert.AreEqual("SSL_CERTIFICATE_PASSWORD", socketSettings.CertificatePassword);
            Assert.AreEqual(SslProtocols.Tls12, socketSettings.SslProtocol);
            Assert.IsFalse(socketSettings.CheckCertificateRevocation);
            Assert.IsTrue(socketSettings.UseSSL);
            Assert.IsFalse(socketSettings.RequireClientCertificate);
        }