// ...but we want a secure SSL connector, too.
// This is the name of the secure connector we want to create.
final String sslConnectorName = "https";
WebJBossASClient client = new WebJBossASClient(mcc);
// because some of the connector attributes do not (yet) support expressions, let's remove any existing
// connector we may have created before and create it again with our current attribute values.
client.removeConnector(sslConnectorName);
LOG.info("Creating https connector...");
ConnectorConfiguration connector = buildSecureConnectorConfiguration(configDirStr, serverProperties);
// verify that we have a truststore file - if user is relying on our self-signed certs, we'll have to create one for them
String truststoreFileString = connector.getSslConfiguration().getCaCertificateFile();
truststoreFileString = resolveExpression(mcc, truststoreFileString);
if (truststoreFileString == null) {
LOG.warn("Missing a valid truststore location - you must specify a valid truststore location!");
} else {
File truststoreFile = new File(truststoreFileString);
if (!truststoreFile.exists()) {
// user didn't provide a truststore file, copy the keystore and use it as the truststore; tell the user about this
String keystoreFileString = connector.getSslConfiguration().getCertificateKeyFile();
keystoreFileString = resolveExpression(mcc, keystoreFileString);
File keystoreFile = new File(keystoreFileString);
if (!keystoreFile.isFile()) {
LOG.warn("Missing both keystore [" + keystoreFile + "] and truststore [" + truststoreFile + "]");
} else {
LOG.warn("Missing the truststore [" + truststoreFile + "] - will copy the keystore ["
+ keystoreFile + "] and make the copy the truststore.");
try {
FileUtil.copyFile(keystoreFile, truststoreFile);
} catch (Exception e) {
LOG.error("Failed to copy keystore to make truststore - a truststore still does not exist", e);
}
}
}
}
if (needProtocolWorkaround) {
connector.setProtocol("org.apache.coyote.http11.Http11Protocol");
}
client.addConnector("https", connector);
LOG.info("https connector created.");
if (client.isConnector(connectorName)) {
client.changeConnector(connectorName, "max-connections",
buildExpression("rhq.server.startup.web.max-connections", serverProperties, true));
client.changeConnector(connectorName, "redirect-port",
buildExpression("rhq.server.socket.binding.port.https", serverProperties, true));
if (needProtocolWorkaround) {
client.changeConnector(connectorName, "protocol", "org.apache.coyote.http11.Http11Protocol");
}
} else {
LOG.warn("There doesn't appear to be a http connector configured already - this is strange.");
}
}