@Test public void testNetClientInternalTLS() throws Exception { client.close(); client = vertx.createNetClient(new NetClientOptions().setSsl(true).setTrustStoreOptions(Trust.SERVER_JKS.get())); testNetClientInternal_(new HttpServerOptions() .setHost("localhost") .setPort(1234) .setSsl(true) .setKeyStoreOptions(Cert.SERVER_JKS.get()), true); }
options.setIdleTimeout(idleTimeout); options.setKeyStoreOptions(keyStoreOptions); options.setTrustStoreOptions(trustStoreOptions); options.addEnabledCipherSuite(enabledCipher); options.setConnectTimeout(connectTimeout);
@Override public MqttClientOptions setTrustStoreOptions(JksOptions options) { super.setTrustStoreOptions(options); return this; }
@Override public ProtonClientOptions setTrustStoreOptions(JksOptions options) { super.setTrustStoreOptions(options); return this; }
@Override public MqttClientOptions setTrustStoreOptions(JksOptions options) { super.setTrustStoreOptions(options); return this; }
@Override public PgConnectOptions setTrustStoreOptions(JksOptions options) { return (PgConnectOptions)super.setTrustStoreOptions(options); }
@Override public PgConnectOptions setTrustStoreOptions(JksOptions options) { return (PgConnectOptions)super.setTrustStoreOptions(options); }
assertEquals(options, options.setTrustStoreOptions(trustStoreOptions)); assertEquals(trustStoreOptions, options.getTrustOptions());
@Test public void testNetClientInternalTLS() throws Exception { client.close(); client = vertx.createNetClient(new NetClientOptions().setSsl(true).setTrustStoreOptions(Trust.SERVER_JKS.get())); testNetClientInternal_(new HttpServerOptions() .setHost("localhost") .setPort(1234) .setSsl(true) .setKeyStoreOptions(Cert.SERVER_JKS.get()), true); }
private void initializeTLSParameters(NetClientOptions options) { String keyStoreType = System.getProperty(JAVAX_NET_SSL_KEYSTORE_TYPE, KeyStore.getDefaultType()); if ("JKS".equalsIgnoreCase(keyStoreType)) { options.setKeyStoreOptions(new JksOptions() .setPath(System.getProperty(JAVAX_NET_SSL_KEYSTORE)) .setPassword(System.getProperty(JAVAX_NET_SSL_KEYSTORE_PASSWORD))); } else { options.setPfxKeyCertOptions(new PfxOptions() .setPath(System.getProperty(JAVAX_NET_SSL_KEYSTORE)) .setPassword(System.getProperty(JAVAX_NET_SSL_KEYSTORE_PASSWORD))); } String trustStoreType = System.getProperty(JAVAX_NET_SSL_TRUSTSTORE_TYPE, KeyStore.getDefaultType()); if ("JKS".equalsIgnoreCase(trustStoreType)) { options.setTrustStoreOptions(new JksOptions() .setPath(System.getProperty(JAVAX_NET_SSL_TRUSTSTORE)) .setPassword(System.getProperty(JAVAX_NET_SSL_TRUSTSTORE_PASSWORD))); } else { options.setPfxTrustOptions(new PfxOptions() .setPath(System.getProperty(JAVAX_NET_SSL_TRUSTSTORE)) .setPassword(System.getProperty(JAVAX_NET_SSL_TRUSTSTORE_PASSWORD))); } String allowedProtocols = System.getProperty(JDK_TLS_CLIENT_PROTOCOLS, "TLSv1.2"); Stream.of(allowedProtocols.split("\\s*,\\s*")) .forEach(options::addEnabledSecureTransportProtocol); String allowedCiphers = System.getProperty(HTTPS_CIPHERSUITES); if (allowedCiphers != null) { Stream.of(allowedCiphers.split("\\s*,\\s*")) .forEach(options::addEnabledCipherSuite); } }
options.setIdleTimeout(idleTimeout); options.setKeyStoreOptions(keyStoreOptions); options.setTrustStoreOptions(trustStoreOptions); options.addEnabledCipherSuite(enabledCipher); options.setConnectTimeout(connectTimeout);
assertEquals(options, options.setTrustStoreOptions(trustStoreOptions)); assertEquals(trustStoreOptions, options.getTrustOptions());