kvm: fix error 'Failed to find passphrase for keystore: cloud.jks' when enable SSL for kvm agent (#7923)

This commit is contained in:
Wei Zhou 2023-12-07 09:10:11 +01:00 committed by GitHub
parent db6dd52f44
commit 7ea068c4dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -14,6 +14,8 @@
*/ */
package com.cloud.agent.properties; package com.cloud.agent.properties;
import org.apache.cloudstack.utils.security.KeyStoreUtils;
/** /**
* Class of constant agent's properties available to configure on * Class of constant agent's properties available to configure on
* "agent.properties". * "agent.properties".
@ -728,6 +730,13 @@ public class AgentProperties{
*/ */
public static final Property<String> CONTROL_CIDR = new Property<>("control.cidr", "169.254.0.0/16"); public static final Property<String> CONTROL_CIDR = new Property<>("control.cidr", "169.254.0.0/16");
/**
* Keystore passphrase
* Data type: String.<br>
* Default value: <code>null</code>
*/
public static final Property<String> KEYSTORE_PASSPHRASE = new Property<>(KeyStoreUtils.KS_PASSPHRASE_PROPERTY, null, String.class);
public static class Property <T>{ public static class Property <T>{
private String name; private String name;
private T defaultValue; private T defaultValue;

View File

@ -1012,7 +1012,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
} }
} }
enableSSLForKvmAgent(params); enableSSLForKvmAgent();
configureLocalStorage(); configureLocalStorage();
/* Directory to use for Qemu sockets like for the Qemu Guest Agent */ /* Directory to use for Qemu sockets like for the Qemu Guest Agent */
@ -1319,13 +1319,13 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
} }
} }
private void enableSSLForKvmAgent(final Map<String, Object> params) { private void enableSSLForKvmAgent() {
final File keyStoreFile = PropertiesUtil.findConfigFile(KeyStoreUtils.KS_FILENAME); final File keyStoreFile = PropertiesUtil.findConfigFile(KeyStoreUtils.KS_FILENAME);
if (keyStoreFile == null) { if (keyStoreFile == null) {
s_logger.info("Failed to find keystore file: " + KeyStoreUtils.KS_FILENAME); s_logger.info("Failed to find keystore file: " + KeyStoreUtils.KS_FILENAME);
return; return;
} }
String keystorePass = (String)params.get(KeyStoreUtils.KS_PASSPHRASE_PROPERTY); String keystorePass = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KEYSTORE_PASSPHRASE);
if (StringUtils.isBlank(keystorePass)) { if (StringUtils.isBlank(keystorePass)) {
s_logger.info("Failed to find passphrase for keystore: " + KeyStoreUtils.KS_FILENAME); s_logger.info("Failed to find passphrase for keystore: " + KeyStoreUtils.KS_FILENAME);
return; return;