// 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.");