/** * Adds a {@link HostnameVerifyingTrustManager} to the supplied config if no trust managers have been configured. A * {@link DefaultTrustManager} is also added in no {@link CredentialConfig} has been configured. * * @deprecated {@link HostnameVerifierConfig} should be used for hostname verification * * @param config to modify * @param names of the hosts to verify */ @Deprecated protected static void addHostnameVerifyingTrustManager(final SslConfig config, final String[] names) { if (config.getTrustManagers() == null) { if (config.getCredentialConfig() == null) { config.setTrustManagers( new DefaultTrustManager(), new HostnameVerifyingTrustManager(new DefaultHostnameVerifier(), names)); } else { config.setTrustManagers(new HostnameVerifyingTrustManager(new DefaultHostnameVerifier(), names)); } } }
/** * Adds a {@link HostnameVerifyingTrustManager} to the supplied config if no trust managers have been configured. A * {@link DefaultTrustManager} is also added in no {@link CredentialConfig} has been configured. * * @deprecated {@link HostnameVerifierConfig} should be used for hostname verification * * @param config to modify * @param names of the hosts to verify */ @Deprecated protected static void addHostnameVerifyingTrustManager(final SslConfig config, final String[] names) { if (config.getTrustManagers() == null) { if (config.getCredentialConfig() == null) { config.setTrustManagers( new DefaultTrustManager(), new HostnameVerifyingTrustManager(new DefaultHostnameVerifier(), names)); } else { config.setTrustManagers(new HostnameVerifyingTrustManager(new DefaultHostnameVerifier(), names)); } } }
/** * Adds a {@link HostnameVerifyingTrustManager} to the supplied config if no trust managers have been configured. A * {@link DefaultTrustManager} is also added in no {@link CredentialConfig} has been configured. * * @param config to modify * @param names of the hosts to verify */ protected static void addHostnameVerifyingTrustManager(final SslConfig config, final String[] names) { if (config.getTrustManagers() == null) { if (config.getCredentialConfig() == null) { config.setTrustManagers( new DefaultTrustManager(), new HostnameVerifyingTrustManager(new DefaultHostnameVerifier(), names)); } else { config.setTrustManagers(new HostnameVerifyingTrustManager(new DefaultHostnameVerifier(), names)); } } }
@Override public TrustManager[] getTrustManagers() throws GeneralSecurityException { final TrustManager[] tm = createTrustManagers(); final TrustManager[] hostnameTrustManager = hostnameVerifierConfig != null ? new TrustManager[] { new HostnameVerifyingTrustManager( hostnameVerifierConfig.getCertificateHostnameVerifier(), hostnameVerifierConfig.getHostnames()), } : null; TrustManager[] aggregate = null; if (tm == null) { if (trustManagers == null) { if (hostnameTrustManager != null) { aggregate = aggregateTrustManagers(new DefaultTrustManager(), hostnameTrustManager[0]); } } else { aggregate = aggregateTrustManagers(LdapUtils.concatArrays(trustManagers, hostnameTrustManager)); } } else { aggregate = aggregateTrustManagers(LdapUtils.concatArrays(tm, trustManagers, hostnameTrustManager)); } return aggregate; }
@Override public TrustManager[] getTrustManagers() throws GeneralSecurityException { final TrustManager[] tm = createTrustManagers(); final TrustManager[] hostnameTrustManager = hostnameVerifierConfig != null ? new TrustManager[] { new HostnameVerifyingTrustManager( hostnameVerifierConfig.getCertificateHostnameVerifier(), hostnameVerifierConfig.getHostnames()), } : null; TrustManager[] aggregate = null; if (tm == null) { if (trustManagers == null) { if (hostnameTrustManager != null) { aggregate = aggregateTrustManagers(new DefaultTrustManager(), hostnameTrustManager[0]); } } else { aggregate = aggregateTrustManagers(LdapUtils.concatArrays(trustManagers, hostnameTrustManager)); } } else { aggregate = aggregateTrustManagers(LdapUtils.concatArrays(tm, trustManagers, hostnameTrustManager)); } return aggregate; }
contextInit = new DefaultSSLContextInitializer(true); contextInit.setTrustManagers( new HostnameVerifyingTrustManager(new DefaultHostnameVerifier(), ldapUrl.getHostnames()));