use of org.jboss.as.test.manualmode.security.TrustAndStoreTrustManager in project wildfly by wildfly.
the class LdapsInitializer method init.
public static IoFilterChainBuilder init(LdapServer server, TcpTransport transport) throws LdapException {
SSLContext sslCtx;
try {
// Initialize the SSLContext to work with our key managers.
sslCtx = SSLContext.getInstance("TLS");
sslCtx.init(server.getKeyManagerFactory().getKeyManagers(), new TrustManager[] { new TrustAndStoreTrustManager() }, new SecureRandom());
} catch (Exception e) {
throw new LdapException(I18n.err(I18n.ERR_683), e);
}
DefaultIoFilterChainBuilder chain = new DefaultIoFilterChainBuilder();
SslFilter sslFilter = new SslFilter(sslCtx);
List<String> cipherSuites = transport.getCipherSuite();
if ((cipherSuites != null) && !cipherSuites.isEmpty()) {
sslFilter.setEnabledCipherSuites(cipherSuites.toArray(new String[cipherSuites.size()]));
}
sslFilter.setWantClientAuth(true);
// The protocols
List<String> enabledProtocols = transport.getEnabledProtocols();
if ((enabledProtocols != null) && !enabledProtocols.isEmpty()) {
sslFilter.setEnabledProtocols(enabledProtocols.toArray(new String[enabledProtocols.size()]));
} else {
// Be sure we disable SSLV3
sslFilter.setEnabledProtocols(new String[] { "TLSv1", "TLSv1.1", "TLSv1.2" });
}
// The remaining SSL parameters
sslFilter.setNeedClientAuth(transport.isNeedClientAuth());
//sslFilter.setWantClientAuth(transport.isWantClientAuth());
chain.addLast("sslFilter", sslFilter);
return chain;
}
Aggregations