public static SSLOption buildFromYaml(String tag) { return buildFromYaml(tag, null); }
public static SSLOption buildFromYaml(String tag, ConcurrentCompositeConfiguration configSource) { SSLOption option = new SSLOption(); option.protocols = getStringProperty(configSource, DEFAULT_OPTION.getProtocols(), "ssl." + tag + ".protocols", "ssl.protocols"); option.ciphers = getStringProperty(configSource, DEFAULT_OPTION.getCiphers(), "ssl." + tag + ".ciphers", "ssl.ciphers"); option.authPeer = getBooleanProperty(configSource, DEFAULT_OPTION.isAuthPeer(), "ssl." + tag + ".authPeer", "ssl.authPeer"); option.checkCNHost = getBooleanProperty(configSource, DEFAULT_OPTION.isCheckCNHost(), "ssl." + tag + ".checkCN.host", "ssl.checkCN.host"); option.checkCNWhite = getBooleanProperty(configSource, DEFAULT_OPTION.isCheckCNWhite(), "ssl." + tag + ".checkCN.white", "ssl.checkCN.white"); option.checkCNWhiteFile = getStringProperty(configSource, DEFAULT_OPTION.getCiphers(), "ssl." + tag + ".checkCN.white.file", "ssl.checkCN.white.file"); option.allowRenegociate = getBooleanProperty(configSource, DEFAULT_OPTION.isAllowRenegociate(), "ssl." + tag + ".allowRenegociate", "ssl.allowRenegociate"); option.storePath =
public static SSLEngine createSSLEngine(SSLOption option, SSLCustom custom) { SSLContext context = createSSLContext(option, custom); SSLEngine engine = context.createSSLEngine(); engine.setEnabledProtocols(option.getProtocols().split(",")); String[] supported = engine.getSupportedCipherSuites(); String[] eanbled = option.getCiphers().split(","); engine.setEnabledCipherSuites(getEnabledCiphers(supported, eanbled)); engine.setNeedClientAuth(option.isAuthPeer()); return engine; }
public static SSLSocketFactory createSSLSocketFactory(SSLOption option, SSLCustom custom) { SSLContext context = createSSLContext(option, custom); SSLSocketFactory factory = context.getSocketFactory(); String[] supported = factory.getSupportedCipherSuites(); String[] eanbled = option.getCiphers().split(","); return new SSLSocketFactoryExt(factory, getEnabledCiphers(supported, eanbled), option.getProtocols().split(",")); }
private static TCPSSLOptions buildTCPSSLOptions(SSLOption sslOption, SSLCustom sslCustom, TCPSSLOptions httpClientOptions) { httpClientOptions.setSsl(true); if (isFileExists(sslCustom.getFullPath(sslOption.getKeyStore()))) { if (STORE_PKCS12.equalsIgnoreCase(sslOption.getKeyStoreType())) { PfxOptions keyPfxOptions = new PfxOptions(); keyPfxOptions.setPath(sslCustom.getFullPath(sslOption.getKeyStore())); keyPfxOptions.setPassword(new String(sslCustom.decode(sslOption.getKeyStoreValue().toCharArray()))); httpClientOptions.setPfxKeyCertOptions(keyPfxOptions); } else if (STORE_JKS.equalsIgnoreCase(sslOption.getKeyStoreType())) { JksOptions keyJksOptions = new JksOptions(); keyJksOptions.setPath(sslCustom.getFullPath(sslOption.getKeyStore())); keyJksOptions.setPassword(new String(sslCustom.decode(sslOption.getKeyStoreValue().toCharArray()))); httpClientOptions.setKeyStoreOptions(keyJksOptions); } else { if (isFileExists(sslCustom.getFullPath(sslOption.getTrustStore()))) { if (STORE_PKCS12.equalsIgnoreCase(sslOption.getTrustStoreType())) { PfxOptions trustPfxOptions = new PfxOptions(); trustPfxOptions.setPath(sslCustom.getFullPath(sslOption.getTrustStore())); trustPfxOptions .setPassword(new String(sslCustom.decode(sslOption.getTrustStoreValue().toCharArray()))); httpClientOptions.setPfxTrustOptions(trustPfxOptions); } else if (STORE_JKS.equalsIgnoreCase(sslOption.getTrustStoreType())) { JksOptions trustJksOptions = new JksOptions(); trustJksOptions.setPath(sslCustom.getFullPath(sslOption.getTrustStore())); trustJksOptions .setPassword(new String(sslCustom.decode(sslOption.getTrustStoreValue().toCharArray()))); httpClientOptions.setTrustStoreOptions(trustJksOptions); } else {
protected void buildSecureClientOptions(HttpClientOptions httpClientOptions) { SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null); SSLOption sslOption; if (factory == null) { sslOption = SSLOption.buildFromYaml(SSL_KEY); } else { sslOption = factory.createSSLOption(); } SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass()); VertxTLSBuilder.buildHttpClientOptions(sslOption, sslCustom, httpClientOptions); } }
public static SSLContext createSSLContext(SSLOption option, SSLCustom custom) { try { String keyStoreName = custom.getFullPath(option.getKeyStore()); KeyManager[] keymanager; if (keyStoreName != null && new File(keyStoreName).exists()) { char[] keyStoreValue = custom.decode(option.getKeyStoreValue().toCharArray()); KeyStore keyStore = KeyStoreUtil.createKeyStore(keyStoreName, option.getKeyStoreType(), keyStoreValue); keymanager = String trustStoreName = custom.getFullPath(option.getTrustStore()); TrustManager[] trustManager; if (trustStoreName != null && new File(trustStoreName).exists()) { char[] trustStoreValue = custom.decode(option.getTrustStoreValue().toCharArray()); KeyStore trustStore = KeyStoreUtil.createKeyStore(trustStoreName, option.getTrustStoreType(), trustStoreValue); trustManager =
private void checkCRL(X509Certificate[] chain) throws CertificateException { String crl = option.getCrl(); crl = custom.getFullPath(crl); File file = new File(crl); if (!file.exists()) { return; } CRL[] crls = KeyStoreUtil.createCRL(crl); X509Certificate owner = CertificateUtil.findOwner(chain); for (CRL c : crls) { if (c.isRevoked(owner)) { LOG.error("certificate revoked"); throw new CertificateException("certificate revoked"); } } }
SSLOption sslOption; if (factory == null) { sslOption = SSLOption.buildFromYaml(sslKey); } else { sslOption = factory.createSSLOption(); SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass()); NetServerOptions serverOptions = new NetServerOptions(); VertxTLSBuilder.buildNetServerOptions(sslOption, sslCustom, serverOptions);
public static SSLEngine createSSLEngine(SSLOption option, SSLCustom custom, String peerHost, int peerPort) { SSLContext context = createSSLContext(option, custom); SSLEngine engine = context.createSSLEngine(peerHost, peerPort); engine.setEnabledProtocols(option.getProtocols().split(",")); String[] supported = engine.getSupportedCipherSuites(); String[] eanbled = option.getCiphers().split(","); engine.setEnabledCipherSuites(getEnabledCiphers(supported, eanbled)); engine.setNeedClientAuth(option.isAuthPeer()); return engine; }
public static SSLSocket createSSLSocket(SSLOption option, SSLCustom custom) { try { SSLContext context = createSSLContext(option, custom); SSLSocketFactory facroty = context.getSocketFactory(); SSLSocket socket = (SSLSocket) facroty.createSocket(); socket.setEnabledProtocols(option.getProtocols().split(",")); String[] supported = socket.getSupportedCipherSuites(); String[] eanbled = option.getCiphers().split(","); socket.setEnabledCipherSuites(getEnabledCiphers(supported, eanbled)); return socket; } catch (UnknownHostException e) { throw new IllegalArgumentException("unkown host"); } catch (IOException e) { throw new IllegalArgumentException("unable create socket"); } }
private HttpClientOptions createHttpClientOptions() { HttpClientOptions httpClientOptions = new HttpClientOptions(); httpClientOptions.setMaxPoolSize(TransportClientConfig.getConnectionMaxPoolSize()); httpClientOptions.setIdleTimeout(TransportClientConfig.getConnectionIdleTimeoutInSeconds()); httpClientOptions.setKeepAlive(TransportClientConfig.getConnectionKeepAlive()); if (this.sslEnabled) { SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null); SSLOption sslOption; if (factory == null) { sslOption = SSLOption.buildFromYaml(SSL_KEY); } else { sslOption = factory.createSSLOption(); } SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass()); VertxTLSBuilder.buildHttpClientOptions(sslOption, sslCustom, httpClientOptions); } return httpClientOptions; }
public static SSLServerSocket createSSLServerSocket(SSLOption option, SSLCustom custom) { try { SSLContext context = createSSLContext(option, custom); SSLServerSocketFactory factory = context.getServerSocketFactory(); SSLServerSocket socket = (SSLServerSocket) factory.createServerSocket(); socket.setEnabledProtocols(option.getProtocols().split(",")); String[] supported = socket.getSupportedCipherSuites(); String[] eanbled = option.getCiphers().split(","); socket.setEnabledCipherSuites(getEnabledCiphers(supported, eanbled)); socket.setNeedClientAuth(option.isAuthPeer()); return socket; } catch (UnknownHostException e) { throw new IllegalArgumentException("unkown host"); } catch (IOException e) { throw new IllegalArgumentException("unable create socket"); } }
private HttpServerOptions createDefaultHttpServerOptions() { HttpServerOptions serverOptions = new HttpServerOptions(); serverOptions.setAcceptBacklog(ACCEPT_BACKLOG); serverOptions.setSendBufferSize(SEND_BUFFER_SIZE); serverOptions.setReceiveBufferSize(RECEIVE_BUFFER_SIZE); serverOptions.setUsePooledBuffers(true); serverOptions.setIdleTimeout(TransportConfig.getConnectionIdleTimeoutInSeconds()); if (endpointObject.isSslEnabled()) { SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null); SSLOption sslOption; if (factory == null) { sslOption = SSLOption.buildFromYaml(SSL_KEY); } else { sslOption = factory.createSSLOption(); } SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass()); VertxTLSBuilder.buildNetServerOptions(sslOption, sslCustom, serverOptions); } return serverOptions; } }