TreeLogger sslLogger = logger.branch(TreeLogger.INFO,
"Listening for SSL connections");
if (sslLogger.isLoggable(TreeLogger.TRACE)) {
sslLogger.log(TreeLogger.TRACE, "Using keystore " + keyStore);
}
SslSocketConnector conn = new SslSocketConnector();
if (clientAuth != null) {
switch (clientAuth) {
case NONE:
conn.setWantClientAuth(false);
conn.setNeedClientAuth(false);
break;
case WANT:
sslLogger.log(TreeLogger.TRACE, "Requesting client certificates");
conn.setWantClientAuth(true);
conn.setNeedClientAuth(false);
break;
case REQUIRE:
sslLogger.log(TreeLogger.TRACE, "Requiring client certificates");
conn.setWantClientAuth(true);
conn.setNeedClientAuth(true);
break;
}
}
conn.setKeystore(keyStore);
conn.setTruststore(keyStore);
conn.setKeyPassword(keyStorePassword);
conn.setTrustPassword(keyStorePassword);
return conn;
}
return new SelectChannelConnector();
}