Skip to content

Commit

Permalink
kvm: fix error 'Failed to find passphrase for keystore: cloud.jks' wh…
Browse files Browse the repository at this point in the history
…en enable SSL for kvm agent (apache#7923)
  • Loading branch information
weizhouapache authored Dec 7, 2023
1 parent db6dd52 commit 7ea068c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
package com.cloud.agent.properties;

import org.apache.cloudstack.utils.security.KeyStoreUtils;

/**
* Class of constant agent's properties available to configure on
* "agent.properties".
Expand Down Expand Up @@ -728,6 +730,13 @@ public Property<Integer> getWorkers() {
*/
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>{
private String name;
private T defaultValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ public boolean configure(final String name, final Map<String, Object> params) th
}
}

enableSSLForKvmAgent(params);
enableSSLForKvmAgent();
configureLocalStorage();

/* Directory to use for Qemu sockets like for the Qemu Guest Agent */
Expand Down Expand Up @@ -1319,13 +1319,13 @@ protected void setupMemoryBalloonStatsPeriod(Connect conn) {
}
}

private void enableSSLForKvmAgent(final Map<String, Object> params) {
private void enableSSLForKvmAgent() {
final File keyStoreFile = PropertiesUtil.findConfigFile(KeyStoreUtils.KS_FILENAME);
if (keyStoreFile == null) {
s_logger.info("Failed to find keystore file: " + KeyStoreUtils.KS_FILENAME);
return;
}
String keystorePass = (String)params.get(KeyStoreUtils.KS_PASSPHRASE_PROPERTY);
String keystorePass = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.KEYSTORE_PASSPHRASE);
if (StringUtils.isBlank(keystorePass)) {
s_logger.info("Failed to find passphrase for keystore: " + KeyStoreUtils.KS_FILENAME);
return;
Expand Down

0 comments on commit 7ea068c

Please sign in to comment.