Skip to content

Commit 8f39a04

Browse files
agent: enable ssl only for kvm agent (not in system vms) (#6371)
* agent: enable ssl only for kvm agent (not in system vms) * Revert "agent: enable ssl only for kvm agent (not in system vms)" This reverts commit b2d76ba. * Revert "KVM: Enable SSL if keystore exists (#6200)" This reverts commit 4525f8c. * KVM: Enable SSL if keystore exists in LibvirtComputingResource.java
1 parent c0124e2 commit 8f39a04

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

agent/src/main/java/com/cloud/agent/AgentShell.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.cloud.utils.backoff.BackoffAlgorithm;
2828
import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
2929
import com.cloud.utils.exception.CloudRuntimeException;
30-
import org.apache.cloudstack.utils.security.KeyStoreUtils;
3130
import org.apache.commons.daemon.Daemon;
3231
import org.apache.commons.daemon.DaemonContext;
3332
import org.apache.commons.daemon.DaemonInitException;
@@ -375,7 +374,6 @@ public void init(String[] args) throws ConfigurationException {
375374

376375
loadProperties();
377376
parseCommand(args);
378-
enableSSL();
379377

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

402-
private void enableSSL() {
403-
final File agentFile = PropertiesUtil.findConfigFile("agent.properties");
404-
if (agentFile == null) {
405-
s_logger.info("Failed to find agent.properties file");
406-
return;
407-
}
408-
String keystorePass = getProperty(null, "keystore.passphrase");
409-
if (StringUtils.isBlank(keystorePass)) {
410-
s_logger.info("Failed to find passphrase for keystore: " + KeyStoreUtils.KS_FILENAME);
411-
return;
412-
}
413-
final String keyStoreFile = agentFile.getParent() + "/" + KeyStoreUtils.KS_FILENAME;
414-
File f = new File(keyStoreFile);
415-
if (f.exists() && !f.isDirectory()) {
416-
System.setProperty("javax.net.ssl.trustStore", keyStoreFile);
417-
System.setProperty("javax.net.ssl.trustStorePassword", keystorePass);
418-
} else {
419-
s_logger.info("Failed to find keystore file: " + keyStoreFile);
420-
}
421-
}
422-
423400
private void launchAgent() throws ConfigurationException {
424401
String resourceClassNames = getProperty(null, "resource");
425402
s_logger.trace("resource=" + resourceClassNames);

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ public boolean configure(final String name, final Map<String, Object> params) th
10201020
}
10211021
}
10221022

1023+
enableSSLForKvmAgent(params);
10231024
configureLocalStorage(params);
10241025

10251026
/* Directory to use for Qemu sockets like for the Qemu Guest Agent */
@@ -1282,6 +1283,23 @@ public boolean configure(final String name, final Map<String, Object> params) th
12821283
return true;
12831284
}
12841285

1286+
private void enableSSLForKvmAgent(final Map<String, Object> params) {
1287+
final File keyStoreFile = PropertiesUtil.findConfigFile(KeyStoreUtils.KS_FILENAME);
1288+
if (keyStoreFile == null) {
1289+
s_logger.info("Failed to find keystore file: " + KeyStoreUtils.KS_FILENAME);
1290+
return;
1291+
}
1292+
String keystorePass = (String)params.get(KeyStoreUtils.KS_PASSPHRASE_PROPERTY);
1293+
if (StringUtils.isBlank(keystorePass)) {
1294+
s_logger.info("Failed to find passphrase for keystore: " + KeyStoreUtils.KS_FILENAME);
1295+
return;
1296+
}
1297+
if (keyStoreFile.exists() && !keyStoreFile.isDirectory()) {
1298+
System.setProperty("javax.net.ssl.trustStore", keyStoreFile.getAbsolutePath());
1299+
System.setProperty("javax.net.ssl.trustStorePassword", keystorePass);
1300+
}
1301+
}
1302+
12851303
protected void configureLocalStorage(final Map<String, Object> params) throws ConfigurationException {
12861304
String localStoragePath = (String)params.get(LOCAL_STORAGE_PATH);
12871305
if (localStoragePath == null) {

0 commit comments

Comments
 (0)