Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: ClientInitializer(SslPolicy sslPolicy, Bucket bucket) throws javax.net.ssl.SSLException
            internal ClientInitializer(SecureClient outerInstance, SslPolicy sslPolicy, Bucket bucket)
            {
                this._outerInstance = outerInstance;
                this.SslContext     = sslPolicy.NettyClientContext();
                this.Bucket         = bucket;
                this.SslPolicy      = sslPolicy;
            }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSupportOpenSSLOnSupportedPlatforms() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSupportOpenSSLOnSupportedPlatforms()
        {
            // depends on the statically linked uber-jar with boring ssl: http://netty.io/wiki/forked-tomcat-native.html
            assumeTrue(SystemUtils.IS_OS_WINDOWS || SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC_OSX);
            assumeThat(System.getProperty("os.arch"), equalTo("x86_64"));
            assumeThat(SystemUtils.JAVA_VENDOR, isOneOf("Oracle Corporation", "Sun Microsystems Inc."));

            // given
            SslResource sslServerResource = selfSignedKeyId(0).trustKeyId(1).install(TestDir.directory("server"));
            SslResource sslClientResource = selfSignedKeyId(1).trustKeyId(0).install(TestDir.directory("client"));

            _server = new SecureServer(SslContextFactory.MakeSslPolicy(sslServerResource, SslProvider.OPENSSL));

            _server.start();
            _client = new SecureClient(SslContextFactory.MakeSslPolicy(sslClientResource, SslProvider.OPENSSL));
            _client.connect(_server.port());

            // when
            ByteBuf request = ByteBufAllocator.DEFAULT.buffer().writeBytes(_request);

            _client.channel().writeAndFlush(request);

            // then
            _expected = ByteBufAllocator.DEFAULT.buffer().writeBytes(SecureServer.Response);
            _client.sslHandshakeFuture().get(1, MINUTES);
            _client.assertResponse(_expected);
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNegotiateCorrectly() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNegotiateCorrectly()
        {
            SslResource sslServerResource = selfSignedKeyId(0).trustKeyId(1).install(TestDir.directory("server"));
            SslResource sslClientResource = selfSignedKeyId(1).trustKeyId(0).install(TestDir.directory("client"));

            _server = new SecureServer(SslContextFactory.MakeSslPolicy(sslServerResource, Setup.serverParams));

            _server.start();
            _client = new SecureClient(SslContextFactory.MakeSslPolicy(sslClientResource, Setup.clientParams));
            _client.connect(_server.port());

            try
            {
                assertTrue(_client.sslHandshakeFuture().get(1, MINUTES).Active);
                assertEquals(Setup.expectedProtocol, _client.protocol());
                assertEquals(Setup.expectedCipher.Substring(4), _client.ciphers().Substring(4));                             // cut away SSL_ or TLS_
            }
            catch (ExecutionException)
            {
                assertFalse(Setup.expectedSuccess);
            }
        }
Пример #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void partiesWithMutualTrustShouldCommunicate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PartiesWithMutualTrustShouldCommunicate()
        {
            // given
            SslResource sslServerResource = selfSignedKeyId(0).trustKeyId(1).install(TestDir.directory("server"));
            SslResource sslClientResource = selfSignedKeyId(1).trustKeyId(0).install(TestDir.directory("client"));

            _server = new SecureServer(SslContextFactory.MakeSslPolicy(sslServerResource));

            _server.start();
            _client = new SecureClient(SslContextFactory.MakeSslPolicy(sslClientResource));
            _client.connect(_server.port());

            // when
            ByteBuf request = ByteBufAllocator.DEFAULT.buffer().writeBytes(_request);

            _client.channel().writeAndFlush(request);

            // then
            _expected = ByteBufAllocator.DEFAULT.buffer().writeBytes(SecureServer.Response);
            _client.sslHandshakeFuture().get(1, MINUTES);
            _client.assertResponse(_expected);
        }
Пример #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void partiesWithMutualTrustThroughCAShouldNotCommunicateWhenClientRevoked() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PartiesWithMutualTrustThroughCAShouldNotCommunicateWhenClientRevoked()
        {
            // given
            SslResource sslServerResource = caSignedKeyId(0).trustSignedByCA().revoke(1).install(TestDir.directory("server"));
            SslResource sslClientResource = caSignedKeyId(1).trustSignedByCA().install(TestDir.directory("client"));

            _server = new SecureServer(SslContextFactory.MakeSslPolicy(sslServerResource));

            _server.start();
            _client = new SecureClient(SslContextFactory.MakeSslPolicy(sslClientResource));
            _client.connect(_server.port());

            try
            {
                _client.sslHandshakeFuture().get(1, MINUTES);
                fail("Client should have been revoked");
            }
            catch (ExecutionException e)
            {
                assertThat(e.InnerException, instanceOf(typeof(SSLException)));
            }
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void clientShouldNotCommunicateWithUntrustedServer() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ClientShouldNotCommunicateWithUntrustedServer()
        {
            // given
            SslResource sslClientResource = selfSignedKeyId(0).trustKeyId(UNRELATED_ID).install(TestDir.directory("client"));
            SslResource sslServerResource = selfSignedKeyId(1).trustKeyId(0).install(TestDir.directory("server"));

            _server = new SecureServer(SslContextFactory.MakeSslPolicy(sslServerResource));

            _server.start();
            _client = new SecureClient(SslContextFactory.MakeSslPolicy(sslClientResource));
            _client.connect(_server.port());

            try
            {
                _client.sslHandshakeFuture().get(1, MINUTES);
                fail();
            }
            catch (ExecutionException e)
            {
                assertThat(e.InnerException, instanceOf(typeof(SSLException)));
            }
        }