volume upload: PSK exchange between managemnet server and SSVM

generated a key during management server start and saved it in
configurationt table
This commit is contained in:
Rajani Karuturi 2014-11-19 17:53:14 +05:30
parent 317606859b
commit 3da3d7418e
2 changed files with 29 additions and 9 deletions

View File

@ -2059,7 +2059,9 @@ public enum Config {
PublishAsynJobEvent("Advanced", ManagementServer.class, Boolean.class, "publish.async.job.events", "true", "enable or disable publishing of usage events on the event bus", null),
// StatsCollector
StatsOutPutGraphiteHost("Advanced", ManagementServer.class, String.class, "stats.output.uri", "", "URI to additionally send StatsCollector statistics to", null);
StatsOutPutGraphiteHost("Advanced", ManagementServer.class, String.class, "stats.output.uri", "", "URI to additionally send StatsCollector statistics to", null),
SSVMPSK("Hidden", ManagementServer.class, String.class, "upload.post.secret.key", "", "PSK with SSVM", null);
private final String _category;
private final Class<?> _componentClass;

View File

@ -303,6 +303,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
// store the public and private keys in the database
updateKeyPairs();
// generate a PSK to communicate with SSVM
updateSecondaryStorageVMSharedKey();
// generate a random password for system vm
updateSystemvmPassword();
@ -962,19 +965,34 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
private void updateSSOKey() {
try {
String encodedKey = null;
// Algorithm for SSO Keys is SHA1, should this be configurable?
KeyGenerator generator = KeyGenerator.getInstance("HmacSHA1");
SecretKey key = generator.generateKey();
encodedKey = Base64.encodeBase64URLSafeString(key.getEncoded());
_configDao.update(Config.SSOKey.key(), Config.SSOKey.getCategory(), encodedKey);
_configDao.update(Config.SSOKey.key(), Config.SSOKey.getCategory(), getPrivateKey());
} catch (NoSuchAlgorithmException ex) {
s_logger.error("error generating sso key", ex);
}
}
/**
* preshared key to be used by management server to communicate with SSVM during volume/template upload
*/
private void updateSecondaryStorageVMSharedKey() {
try {
_configDao.update(Config.SSVMPSK.key(), Config.SSVMPSK.getCategory(), getPrivateKey());
} catch (NoSuchAlgorithmException ex) {
s_logger.error("error generating ssvm psk", ex);
}
}
private String getPrivateKey() throws NoSuchAlgorithmException {
String encodedKey = null;
// Algorithm for generating Key is SHA1, should this be configurable?
KeyGenerator generator = KeyGenerator.getInstance("HmacSHA1");
SecretKey key = generator.generateKey();
encodedKey = Base64.encodeBase64URLSafeString(key.getEncoded());
return encodedKey;
}
@DB
protected HostPodVO createPod(long userId, String podName, final long zoneId, String gateway, String cidr, final String startIp, String endIp)
throws InternalErrorException {