//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); }
public static SslPolicy MakeSslPolicy(SslResource sslResource, SslProvider sslProvider, string protocols, string ciphers) { IDictionary <string, string> config = new Dictionary <string, string>(); config[SslSystemSettings.netty_ssl_provider.name()] = sslProvider.name(); SslPolicyConfig policyConfig = new SslPolicyConfig("default"); File baseDirectory = sslResource.PrivateKey().ParentFile; (new File(baseDirectory, "trusted")).mkdirs(); (new File(baseDirectory, "revoked")).mkdirs(); config[policyConfig.BaseDirectory.name()] = baseDirectory.Path; config[policyConfig.PrivateKey.name()] = sslResource.PrivateKey().Path; config[policyConfig.PublicCertificate.name()] = sslResource.PublicCertificate().Path; config[policyConfig.TrustedDir.name()] = sslResource.TrustedDirectory().Path; config[policyConfig.RevokedDir.name()] = sslResource.RevokedDirectory().Path; config[policyConfig.VerifyHostname.name()] = "false"; if (!string.ReferenceEquals(protocols, null)) { config[policyConfig.TlsVersions.name()] = protocols; } if (!string.ReferenceEquals(ciphers, null)) { config[policyConfig.Ciphers.name()] = ciphers; } SslPolicyLoader sslPolicyFactory = SslPolicyLoader.create(Config.fromSettings(config).build(), NullLogProvider.Instance); return(sslPolicyFactory.GetPolicy("default")); }
//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); } }
//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); }
//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))); } }
//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))); } }
public static SslPolicy MakeSslPolicy(SslResource sslResource) { return(MakeSslPolicy(sslResource, SslProvider.JDK, null, null)); }
public static SslPolicy MakeSslPolicy(SslResource sslResource, SslParameters @params) { return(MakeSslPolicy(sslResource, SslProvider.JDK, @params.ProtocolsConflict, @params.CiphersConflict)); }