private void handleSSLConfig(Node node, ClientNetworkConfig clientNetworkConfig) { SSLConfig sslConfig = new SSLConfig(); NamedNodeMap atts = node.getAttributes(); Node enabledNode = atts.getNamedItem("enabled"); boolean enabled = enabledNode != null && getBooleanValue(getTextContent(enabledNode).trim()); sslConfig.setEnabled(enabled); for (Node n : childElements(node)) { String nodeName = cleanNodeName(n); if ("factory-class-name".equals(nodeName)) { sslConfig.setFactoryClassName(getTextContent(n).trim()); } else if ("properties".equals(nodeName)) { fillProperties(n, sslConfig.getProperties()); } } clientNetworkConfig.setSSLConfig(sslConfig); }
private static void ssl(XmlGenerator gen, SSLConfig ssl) { if (ssl == null) { return; } gen.open("ssl", "enabled", ssl.isEnabled()) .node("factory-class-name", classNameOrImplClass(ssl.getFactoryClassName(), ssl.getFactoryImplementation())) .appendProperties(ssl.getProperties()) .close(); }
@Bean public HazelcastInstance hazelcastClient() { Properties clientSslProps = new Properties(); clientSslProps.setProperty("trustStore", tsFile.getAbsolutePath()); clientSslProps.setProperty("trustStorePassword", PASSWORD); clientConfig.getNetworkConfig().setSSLConfig(new SSLConfig().setEnabled(true).setProperties(clientSslProps)); clientConfig.setLicenseKey(LICENSE_KEY); return HazelcastClient.newHazelcastClient(clientConfig); }
public static void main(String[] args) throws Exception { SSLConfig sslConfig = new SSLConfig(); sslConfig.setEnabled(true); sslConfig.setFactoryClassName("com.hazelcast.nio.ssl.BasicSSLContextFactory"); sslConfig.setProperty("keyStore", new File("hazelcast.ks").getAbsolutePath()); sslConfig.setProperty("keyStorePassword", "password"); sslConfig.setProperty("javax.net.ssl.trustStore", new File("hazelcast.ts").getAbsolutePath()); Config config = new Config(); config.setLicenseKey(ENTERPRISE_LICENSE_KEY); config.getNetworkConfig().setSSLConfig(sslConfig); HazelcastInstance hz = Hazelcast.newHazelcastInstance(config); System.out.println("Hazelcast Member instance is running!"); BlockingQueue<String> queue = hz.getQueue("queue"); for (; ; ) { System.out.println(queue.take()); } } }
@Bean public ClientConfig hazelcastConfig() { ClientConfig config = new ClientConfig(); config.getNetworkConfig().getKubernetesConfig().setEnabled(true); config.getNetworkConfig().setSSLConfig(new SSLConfig() .setProperty("trustStore", "truststore") .setProperty("trustStorePassword", System.getenv("KEYSTORE_PASSWORD")) .setEnabled(true)); return config; }
netCfg.setJoin(joinCfg); netCfg.setSSLConfig(new SSLConfig().setEnabled(false));
RestAssured.config = RestAssured.newConfig().sslConfig(new SSLConfig("/truststore_javanet.jks", "test1234");
@Override public ChannelInitializer createChannelInitializer(IOService ioService) { SSLConfig sslConfig = ioService.getSSLConfig(); if (sslConfig != null && sslConfig.isEnabled()) { if (!BuildInfoProvider.getBuildInfo().isEnterprise()) { throw new IllegalStateException("SSL/TLS requires Hazelcast Enterprise Edition"); } } return new PlainChannelInitializer(ioService); }
public static void main(String[] args) throws Exception { SSLConfig sslConfig = new SSLConfig(); sslConfig.setEnabled(true); sslConfig.setFactoryClassName("com.hazelcast.nio.ssl.BasicSSLContextFactory"); sslConfig.setProperty("keyStore", new File("hazelcast.ks").getAbsolutePath()); sslConfig.setProperty("keyStorePassword", "password"); sslConfig.setProperty("javax.net.ssl.trustStore", new File("hazelcast.ts").getAbsolutePath()); ClientConfig clientConfig = new ClientConfig(); clientConfig.setLicenseKey(ENTERPRISE_LICENSE_KEY); clientConfig.getNetworkConfig().addAddress("127.0.0.1"); clientConfig.getNetworkConfig().setSSLConfig(sslConfig); HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig); System.out.println(clientConfig.toString()); BlockingQueue<String> queue = client.getQueue("queue"); queue.put("Hello!"); System.out.println("Message sent by Hazelcast Client!"); HazelcastClient.shutdownAll(); } }
joinConfig.setAwsConfig(awsConfig); final SSLConfig sslConfig = new SSLConfig(); sslConfig.setEnabled(false); networkConfig.setSSLConfig(sslConfig);
KeyStore keyStore = null; SSLConfig config = null; try { keyStore = KeyStore.getInstance("PKCS12"); keyStore.load( new FileInputStream("certs/client_cert_and_private.p12"), password.toCharArray()); } catch (Exception ex) { System.out.println("Error while loading keystore >>>>>>>>>"); ex.printStackTrace(); } if (keyStore != null) { org.apache.http.conn.ssl.SSLSocketFactory clientAuthFactory = new org.apache.http.conn.ssl.SSLSocketFactory(keyStore, password); // set the config in rest assured config = new SSLConfig().with().sslSocketFactory(clientAuthFactory).and().allowAllHostnames(); RestAssured.config = RestAssured.config().sslConfig(config); RestAssured.given().when().get("/path").then();
@Override public ChannelInitializer createChannelInitializer(IOService ioService) { SSLConfig sslConfig = ioService.getSSLConfig(); if (sslConfig != null && sslConfig.isEnabled()) { if (!BuildInfoProvider.getBuildInfo().isEnterprise()) { throw new IllegalStateException("SSL/TLS requires Hazelcast Enterprise Edition"); } } return new PlainChannelInitializer(ioService); }
private void handleSSLConfig(Node node, ClientNetworkConfig clientNetworkConfig) { SSLConfig sslConfig = new SSLConfig(); NamedNodeMap atts = node.getAttributes(); Node enabledNode = atts.getNamedItem("enabled"); boolean enabled = enabledNode != null && getBooleanValue(getTextContent(enabledNode).trim()); sslConfig.setEnabled(enabled); for (Node n : childElements(node)) { String nodeName = cleanNodeName(n); if ("factory-class-name".equals(nodeName)) { sslConfig.setFactoryClassName(getTextContent(n).trim()); } else if ("properties".equals(nodeName)) { fillProperties(n, sslConfig.getProperties()); } } clientNetworkConfig.setSSLConfig(sslConfig); }
private static void ssl(XmlGenerator gen, SSLConfig ssl) { if (ssl == null) { return; } gen.open("ssl", "enabled", ssl.isEnabled()) .node("factory-class-name", classNameOrImplClass(ssl.getFactoryClassName(), ssl.getFactoryImplementation())) .appendProperties(ssl.getProperties()) .close(); }
SSLConfig ssl = new SSLConfig(){ @Override public SSLContext createSSLContext() { try{ //Load the keystore. KeyStore keyStore=KeyStore.getInstance(KeyStore.getDefaultType()); InputStream keyStream=ClassLoader.getSystemResourceAsStream("my.jks"); //InputStream keyStream=new java.net.URL("jar:file:/C:/dir/my.jar!/my.jks").openStream(); keyStore.load(keyStream,"mypassword"); keyStream.close(); //Create the factory from the keystore. String kmfAlgorithm=System.getProperty("ssl.KeyManagerFactory.algorithm",KeyManagerFactory.getDefaultAlgorithm()); KeyManagerFactory keyManagerFactory=KeyManagerFactory.getInstance(kmfAlgorithm); keyManagerFactory.init(keyStore,"mypassword"); //Create the SSLContext SSLContext sslContext=SSLContext.getInstance("TLS"); sslContext.init(keyManagerFactory.getKeyManagers(), null, null); return sslContext; } //Wrap all Exceptions in a RuntimeException. catch(Exception e){ throw new RuntimeException(e); } } };
@Override public ChannelInitializer createChannelInitializer() { ClientNetworkConfig networkConfig = client.getClientConfig().getNetworkConfig(); SSLConfig sslConfig = networkConfig.getSSLConfig(); if (sslConfig != null && sslConfig.isEnabled()) { if (!BuildInfoProvider.getBuildInfo().isEnterprise()) { throw new IllegalStateException("SSL/TLS requires Hazelcast Enterprise Edition"); } } SocketOptions socketOptions = networkConfig.getSocketOptions(); HazelcastProperties properties = client.getProperties(); boolean directBuffer = properties.getBoolean(SOCKET_CLIENT_BUFFER_DIRECT); return new ClientPlainChannelInitializer(socketOptions, directBuffer); }
private void handleSSLConfig(Node node) { SSLConfig sslConfig = new SSLConfig(); NamedNodeMap attributes = node.getAttributes(); Node enabledNode = attributes.getNamedItem("enabled"); boolean enabled = enabledNode != null && getBooleanValue(getTextContent(enabledNode).trim()); sslConfig.setEnabled(enabled); for (Node n : childElements(node)) { String nodeName = cleanNodeName(n); if ("factory-class-name".equals(nodeName)) { sslConfig.setFactoryClassName(getTextContent(n).trim()); } else if ("properties".equals(nodeName)) { fillProperties(n, sslConfig.getProperties()); } } config.getNetworkConfig().setSSLConfig(sslConfig); }
private void sslConfigXmlGenerator(XmlGenerator gen, NetworkConfig netCfg) { SSLConfig ssl = netCfg.getSSLConfig(); gen.open("ssl", "enabled", ssl != null && ssl.isEnabled()); if (ssl != null) { Properties props = new Properties(); props.putAll(ssl.getProperties()); if (maskSensitiveFields && props.containsKey("trustStorePassword")) { props.setProperty("trustStorePassword", MASK_FOR_SENSITIVE_DATA); } if (maskSensitiveFields && props.containsKey("keyStorePassword")) { props.setProperty("keyStorePassword", MASK_FOR_SENSITIVE_DATA); } gen.node("factory-class-name", classNameOrImplClass(ssl.getFactoryClassName(), ssl.getFactoryImplementation())) .appendProperties(props); } gen.close(); }
public ClientNetworkConfig(ClientNetworkConfig networkConfig) { addressList = new ArrayList<String>(networkConfig.addressList); smartRouting = networkConfig.smartRouting; redoOperation = networkConfig.redoOperation; connectionTimeout = networkConfig.connectionTimeout; connectionAttemptLimit = networkConfig.connectionAttemptLimit; connectionAttemptPeriod = networkConfig.connectionAttemptPeriod; socketInterceptorConfig = new SocketInterceptorConfig(networkConfig.socketInterceptorConfig); socketOptions = new SocketOptions(networkConfig.socketOptions); sslConfig = networkConfig.sslConfig == null ? null : new SSLConfig(networkConfig.sslConfig); awsConfig = new ClientAwsConfig(networkConfig.awsConfig); gcpConfig = new GcpConfig(networkConfig.gcpConfig); azureConfig = new AzureConfig(networkConfig.azureConfig); kubernetesConfig = new KubernetesConfig(networkConfig.kubernetesConfig); eurekaConfig = new EurekaConfig(networkConfig.eurekaConfig); cloudConfig = new ClientCloudConfig(networkConfig.cloudConfig); discoveryConfig = new DiscoveryConfig(networkConfig.discoveryConfig); outboundPortDefinitions = networkConfig.outboundPortDefinitions == null ? null : new HashSet<String>(networkConfig.outboundPortDefinitions); outboundPorts = networkConfig.outboundPorts == null ? null : new HashSet<Integer>(networkConfig.outboundPorts); clientIcmpPingConfig = new ClientIcmpPingConfig(networkConfig.clientIcmpPingConfig); }
@Override public ChannelInitializer createChannelInitializer() { ClientNetworkConfig networkConfig = client.getClientConfig().getNetworkConfig(); SSLConfig sslConfig = networkConfig.getSSLConfig(); if (sslConfig != null && sslConfig.isEnabled()) { if (!BuildInfoProvider.getBuildInfo().isEnterprise()) { throw new IllegalStateException("SSL/TLS requires Hazelcast Enterprise Edition"); } } SocketOptions socketOptions = networkConfig.getSocketOptions(); HazelcastProperties properties = client.getProperties(); boolean directBuffer = properties.getBoolean(SOCKET_CLIENT_BUFFER_DIRECT); return new ClientPlainChannelInitializer(socketOptions, directBuffer); }