| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,7 @@ | |||
| 27 | 27 | import com.cloud.utils.backoff.BackoffAlgorithm; | |
| 28 | 28 | import com.cloud.utils.backoff.impl.ConstantTimeBackoff; | |
| 29 | 29 | import com.cloud.utils.exception.CloudRuntimeException; | |
| 30 | + import org.apache.cloudstack.utils.security.KeyStoreUtils; | ||
| 30 | 31 | import org.apache.commons.daemon.Daemon; | |
| 31 | 32 | import org.apache.commons.daemon.DaemonContext; | |
| 32 | 33 | import org.apache.commons.daemon.DaemonInitException; | |
@@ -374,6 +375,7 @@ public void init(String[] args) throws ConfigurationException { | |||
| 374 | 375 | ||
| 375 | 376 | loadProperties(); | |
| 376 | 377 | parseCommand(args); | |
| 378 | + enableSSL(); | ||
| 377 | 379 | ||
| 378 | 380 | if (s_logger.isDebugEnabled()) { | |
| 379 | 381 | List<String> properties = Collections.list((Enumeration<String>)_properties.propertyNames()); | |
@@ -397,6 +399,27 @@ public void init(String[] args) throws ConfigurationException { | |||
| 397 | 399 | _backoff.configure("ConstantTimeBackoff", new HashMap<String, Object>()); | |
| 398 | 400 | } | |
| 399 | 401 | ||
| 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 | + | ||
| 400 | 423 | private void launchAgent() throws ConfigurationException { | |
| 401 | 424 | String resourceClassNames = getProperty(null, "resource"); | |
| 402 | 425 | s_logger.trace("resource=" + resourceClassNames); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments