mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
KVM: Enable SSL if keystore exists (#6200)
* KVM: Enable SSL if keystore exists * Update #6200: add logs if no passphrase or no keystore
This commit is contained in:
parent
bba38fa2ea
commit
4525f8c8e7
@ -27,6 +27,7 @@ import com.cloud.utils.PropertiesUtil;
|
||||
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;
|
||||
@ -374,6 +375,7 @@ public class AgentShell implements IAgentShell, Daemon {
|
||||
|
||||
loadProperties();
|
||||
parseCommand(args);
|
||||
enableSSL();
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
List<String> properties = Collections.list((Enumeration<String>)_properties.propertyNames());
|
||||
@ -397,6 +399,27 @@ public class AgentShell implements IAgentShell, Daemon {
|
||||
_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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user