/** * Constructor that allows you creating empty configuration. * * @param readSystemProperties * If <code>true</code> populates configuration from * {@link System#getProperties()}, else you have empty * configuration. */ public SSLContextConfigurator(boolean readSystemProperties) { if (readSystemProperties) { retrieve(System.getProperties()); } }
/** * Constructor that allows you creating empty configuration. * * @param readSystemProperties * If <code>true</code> populates configuration from * {@link System#getProperties()}, else you have empty * configuration. */ public SSLContextConfigurator(boolean readSystemProperties) { if (readSystemProperties) { retrieve(System.getProperties()); } }
/** * Constructor that allows you creating empty configuration. * * @param readSystemProperties * If <code>true</code> populates configuration from * {@link System#getProperties()}, else you have empty * configuration. */ public SSLContextConfigurator(boolean readSystemProperties) { if (readSystemProperties) { retrieve(System.getProperties()); } }
/** * Constructor that allows you creating empty configuration. * * @param readSystemProperties * If <code>true</code> populates configuration from * {@link System#getProperties()}, else you have empty * configuration. */ public SSLContextConfigurator(boolean readSystemProperties) { if (readSystemProperties) { retrieve(System.getProperties()); } }
/** * Constructor that allows you creating empty configuration. * * @param readSystemProperties * If <code>true</code> populates configuration from * {@link System#getProperties()}, else you have empty * configuration. */ public SSLContextConfigurator(boolean readSystemProperties) { if (readSystemProperties) { retrieve(System.getProperties()); } }
/** * Constructor that allows you creating empty configuration. * * @param readSystemProperties * If <code>true</code> populates configuration from * {@link System#getProperties()}, else you have empty * configuration. */ public SSLContextConfigurator(boolean readSystemProperties) { if (readSystemProperties) { retrieve(System.getProperties()); } }
/** * Constructor that allows you creating empty configuration. * * @param readSystemProperties * If <code>true</code> populates configuration from * {@link System#getProperties()}, else you have empty * configuration. */ public SSLContextConfigurator(boolean readSystemProperties) { if (readSystemProperties) { retrieve(System.getProperties()); } }
/** * Constructor that allows you creating empty configuration. * * @param readSystemProperties * If <code>true</code> populates configuration from * {@link System#getProperties()}, else you have empty * configuration. */ public SSLContextConfigurator(boolean readSystemProperties) { if (readSystemProperties) { retrieve(System.getProperties()); } }
/** * Constructor that allows you creating empty configuration. * * @param readSystemProperties * If <code>true</code> populates configuration from * {@link System#getProperties()}, else you have empty * configuration. */ public SSLContextConfigurator(boolean readSystemProperties) { if (readSystemProperties) { retrieve(System.getProperties()); } }
/** * Constructor that allows you creating empty configuration. * * @param readSystemProperties * If <code>true</code> populates configuration from * {@link System#getProperties()}, else you have empty * configuration. */ public SSLContextConfigurator(boolean readSystemProperties) { if (readSystemProperties) { retrieve(System.getProperties()); } }
/** * Constructor that allows you creating empty configuration. * * @param readSystemProperties * If <code>true</code> populates configuration from * {@link System#getProperties()}, else you have empty * configuration. */ public SSLContextConfigurator(boolean readSystemProperties) { if (readSystemProperties) { retrieve(System.getProperties()); } }
/** * Constructor that allows you creating empty configuration. * * @param readSystemProperties * If <code>true</code> populates configuration from * {@link System#getProperties()}, else you have empty * configuration. */ public SSLContextConfigurator(boolean readSystemProperties) { if (readSystemProperties) { retrieve(System.getProperties()); } }
client = ClientManager.createClient(); //System.getProperties().put("javax.net.debug", "all"); // Useful for debugging SSL interaction // The keystore in the next two lines is the same keystore you used for running the server, // likely in ${jetty.base}/etc/keystore System.getProperties().put(SSLContextConfigurator.KEY_STORE_FILE, "/tmp/keystore"); System.getProperties().put(SSLContextConfigurator.TRUST_STORE_FILE, "/tmp/keystore"); // The following two passwords are what you used for your self-signed cert System.getProperties().put(SSLContextConfigurator.KEY_STORE_PASSWORD, "HumanReadablePassword"); System.getProperties().put(SSLContextConfigurator.TRUST_STORE_PASSWORD, "HumanReadablePassword"); final SSLContextConfigurator defaultConfig = new SSLContextConfigurator(); defaultConfig.retrieve(System.getProperties()); // or setup SSLContextConfigurator using its API. SSLEngineConfigurator sslEngineConfigurator = new SSLEngineConfigurator(defaultConfig, true, false, false); client.getProperties().put(GrizzlyEngine.SSL_ENGINE_CONFIGURATOR, sslEngineConfigurator); client.connectToServer(sillyWebSocketClient , ClientEndpointConfig.Builder.create().build(), new URI("wss://localhost:8443/sillyWebSocketServer/echo")); System.out.println ("Connected .... ");
private ExtendedSSLEngineConfigurator getSSLEngineConfigurator(URI uri, Map<String, Object> properties) { Object configuratorObject = properties.get(ClientProperties.SSL_ENGINE_CONFIGURATOR); if (configuratorObject == null) { // if we are trying to access "wss" scheme and we don't have sslEngineConfigurator instance // we should try to create ssl connection using JVM properties. if ("wss".equalsIgnoreCase(uri.getScheme())) { final SSLContextConfigurator defaultConfig = new SSLContextConfigurator(); defaultConfig.retrieve(System.getProperties()); return new ExtendedSSLEngineConfigurator(defaultConfig.createSSLContext(), uri.getHost()); } else { return null; } } if (configuratorObject instanceof SSLEngineConfigurator) { return new ExtendedSSLEngineConfigurator((SSLEngineConfigurator) configuratorObject, uri.getHost()); } if (configuratorObject instanceof SslEngineConfigurator) { return new ExtendedSSLEngineConfigurator((SslEngineConfigurator) configuratorObject, uri.getHost()); } // if we have reached here the ssl engine configuration property is set, but is of incompatible type LOGGER.log(Level.CONFIG, String.format("Invalid type of configuration property of %s (%s), %s cannot be cast to %s or %s", ClientProperties.SSL_ENGINE_CONFIGURATOR, configuratorObject.toString(), configuratorObject.getClass().toString(), SSLEngineConfigurator.class.toString(), SslEngineConfigurator.class.toString())); return null; }
private ExtendedSSLEngineConfigurator getSSLEngineConfigurator(URI uri, Map<String, Object> properties) { Object configuratorObject = properties.get(ClientProperties.SSL_ENGINE_CONFIGURATOR); if (configuratorObject == null) { // if we are trying to access "wss" scheme and we don't have sslEngineConfigurator instance // we should try to create ssl connection using JVM properties. if ("wss".equalsIgnoreCase(uri.getScheme())) { final SSLContextConfigurator defaultConfig = new SSLContextConfigurator(); defaultConfig.retrieve(System.getProperties()); return new ExtendedSSLEngineConfigurator(defaultConfig.createSSLContext(), uri.getHost()); } else { return null; } } if (configuratorObject instanceof SSLEngineConfigurator) { return new ExtendedSSLEngineConfigurator((SSLEngineConfigurator) configuratorObject, uri.getHost()); } if (configuratorObject instanceof SslEngineConfigurator) { return new ExtendedSSLEngineConfigurator((SslEngineConfigurator) configuratorObject, uri.getHost()); } // if we have reached here the ssl engine configuration property is set, but is of incompatible type LOGGER.log(Level.CONFIG, String.format("Invalid type of configuration property of %s (%s), %s cannot be cast to %s or %s", ClientProperties.SSL_ENGINE_CONFIGURATOR, configuratorObject.toString(), configuratorObject.getClass().toString(), SSLEngineConfigurator.class.toString(), SslEngineConfigurator.class.toString())); return null; }
@Override public TyrusClientSocket openClientSocket(String url, ClientEndpointConfig cec, SPIEndpoint endpoint, SPIHandshakeListener listener, Map<String, Object> properties) throws DeploymentException { URI uri; try { uri = new URI(url); } catch (URISyntaxException e) { throw new DeploymentException("Invalid URI.", e); } SSLEngineConfigurator sslEngineConfigurator = (properties == null ? null : (SSLEngineConfigurator) properties.get(SSL_ENGINE_CONFIGURATOR)); // if we are trying to access "wss" scheme and we don't have sslEngineConfigurator instance // we should try to create ssl connection using JVM properties. if(uri.getScheme().equalsIgnoreCase("wss") && sslEngineConfigurator == null) { SSLContextConfigurator defaultConfig = new SSLContextConfigurator(); defaultConfig.retrieve(System.getProperties()); sslEngineConfigurator = new SSLEngineConfigurator(defaultConfig, true, false, false); } GrizzlyClientSocket clientSocket = new GrizzlyClientSocket(endpoint, uri, cec, CLIENT_SOCKET_TIMEOUT, listener, properties == null ? null : sslEngineConfigurator, properties == null ? null : (String) properties.get(GrizzlyClientSocket.PROXY_URI), properties == null ? null : (ThreadPoolConfig) properties.get(GrizzlyClientSocket.WORKER_THREAD_POOL_CONFIG), properties == null ? null : (ThreadPoolConfig) properties.get(GrizzlyClientSocket.SELECTOR_THREAD_POOL_CONFIG)); clientSocket.connect(); return clientSocket; } }