Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions agent/src/main/java/com/cloud/agent/AgentShell.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.cloud.utils.backoff.BackoffAlgorithm;
import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.cloudstack.utils.security.KeyStoreUtils;
import org.apache.commons.daemon.Daemon;
import org.apache.commons.daemon.DaemonContext;
import org.apache.commons.daemon.DaemonInitException;
Expand Down Expand Up @@ -374,6 +375,7 @@ public void init(String[] args) throws ConfigurationException {

loadProperties();
parseCommand(args);
enableSSL();

if (s_logger.isDebugEnabled()) {
List<String> properties = Collections.list((Enumeration<String>)_properties.propertyNames());
Expand All @@ -397,6 +399,27 @@ public void init(String[] args) throws ConfigurationException {
_backoff.configure("ConstantTimeBackoff", new HashMap<String, Object>());
}

private void enableSSL() {
final File agentFile = PropertiesUtil.findConfigFile("agent.properties");
if (agentFile == null) {
s_logger.info("Failed to find agent.properties file");
return;
}
String keystorePass = getProperty(null, "keystore.passphrase");
if (StringUtils.isBlank(keystorePass)) {
s_logger.info("Failed to find passphrase for keystore: " + KeyStoreUtils.KS_FILENAME);
return;
}
final String keyStoreFile = agentFile.getParent() + "/" + KeyStoreUtils.KS_FILENAME;
File f = new File(keyStoreFile);
if (f.exists() && !f.isDirectory()) {
System.setProperty("javax.net.ssl.trustStore", keyStoreFile);
System.setProperty("javax.net.ssl.trustStorePassword", keystorePass);
} else {
s_logger.info("Failed to find keystore file: " + keyStoreFile);
}
}

private void launchAgent() throws ConfigurationException {
String resourceClassNames = getProperty(null, "resource");
s_logger.trace("resource=" + resourceClassNames);
Expand Down