public void initChannel(Channel channel) throws Exception
{
ChannelPipeline pipeline = channel.pipeline();
if (sslEnabled)
{
SSLEngine engine = context.createSSLEngine();
engine.setUseClientMode(false);
if (needClientAuth)
engine.setNeedClientAuth(true);
// setting the enabled cipher suites resets the enabled protocols so we need
// to save the enabled protocols so that after the customer cipher suite is enabled
// we can reset the enabled protocols if a customer protocol isn't specified
String[] originalProtocols = engine.getEnabledProtocols();
if (enabledCipherSuites != null)
{
try
{
engine.setEnabledCipherSuites(SSLSupport.parseCommaSeparatedListIntoArray(enabledCipherSuites));
}
catch (IllegalArgumentException e)
{
HornetQServerLogger.LOGGER.invalidCipherSuite(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedCipherSuites()));
throw e;
}
}
if (enabledProtocols != null)
{
try
{
engine.setEnabledProtocols(SSLSupport.parseCommaSeparatedListIntoArray(enabledProtocols));
}
catch (IllegalArgumentException e)
{
HornetQServerLogger.LOGGER.invalidProtocol(SSLSupport.parseArrayIntoCommandSeparatedList(engine.getSupportedProtocols()));
throw e;
}
}
else
{
engine.setEnabledProtocols(originalProtocols);
}
SslHandler handler = new SslHandler(engine);
pipeline.addLast("ssl", handler);