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")); }
private static SslContext CreateSslContext(SslPolicyLoader sslPolicyFactory, Config config) { try { string policyName = config.Get(GraphDatabaseSettings.bolt_ssl_policy); if (string.ReferenceEquals(policyName, null)) { throw new System.ArgumentException("No SSL policy has been configured for Bolt server"); } return(sslPolicyFactory.GetPolicy(policyName).nettyServerContext()); } catch (Exception e) { throw new Exception("Failed to initialize SSL encryption support, which is required to start this connector. " + "Error was: " + e.Message, e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 120_000) public void shouldBeAbleToStartAndStoreWithoutSuccessfulJoin() public virtual void ShouldBeAbleToStartAndStoreWithoutSuccessfulJoin() { // given IDictionary <string, string> @params = stringMap(); SslPolicyConfig policyConfig = new SslPolicyConfig("default"); @params[neo4j_home.name()] = _home.AbsolutePath; @params[policyConfig.BaseDirectory.name()] = "certificates/default"; JobScheduler jobScheduler = JobSchedulerFactory.createInitialisedScheduler(); PlatformModule platformModule = new PlatformModule(TestDirectory.storeDir(), Config.defaults(), ENTERPRISE, newDependencies()); AbstractEditionModule editionModule = new EnterpriseEditionModule(platformModule); // Random members that does not exists, discovery will never succeed string initialHosts = "localhost:" + PortAuthority.allocatePort() + ",localhost:" + PortAuthority.allocatePort(); Config config = config(); config.augment(initial_discovery_members, initialHosts); // Setup SslPolicy config.augment(neo4j_home.name(), _home.AbsolutePath); config.Augment(policyConfig.BaseDirectory.name(), "certificates/default"); SslPolicyLoader sslPolicyLoader = SslPolicyLoader.create(config, NullLogProvider.Instance); RemoteMembersResolver remoteMembersResolver = ResolutionResolverFactory.ChooseResolver(config, platformModule.Logging); // then SslPolicy sslPolicy = sslPolicyLoader.GetPolicy("default"); Monitors monitors = new Monitors(); SecureHazelcastCoreTopologyService service = new SecureHazelcastCoreTopologyService(config, sslPolicy, new MemberId(System.Guid.randomUUID()), jobScheduler, NullLogProvider.Instance, NullLogProvider.Instance, remoteMembersResolver, new TopologyServiceNoRetriesStrategy(), monitors); try { service.Init(); service.Start(); service.Stop(); } catch (Exception) { fail("Caught an Exception"); } }