You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by we...@apache.org on 2013/07/12 11:35:50 UTC
[2/4] git commit: updated refs/heads/4.1 to 3b5bcac
CLOUDSTACK-3362: use POST instead of GET and encode/decode cert/key in uploadCustomCertificate
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7b2f68e8
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7b2f68e8
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7b2f68e8
Branch: refs/heads/4.1
Commit: 7b2f68e8cfaea5f313ff91da90a4ac62e5933afa
Parents: 5174b00
Author: Wei Zhou <w....@leaseweb.com>
Authored: Thu Jul 11 16:06:21 2013 +0200
Committer: Wei Zhou <w....@leaseweb.com>
Committed: Fri Jul 12 11:18:51 2013 +0200
----------------------------------------------------------------------
.../com/cloud/server/ManagementServerImpl.java | 24 ++++++++++++++++----
ui/scripts/ui-custom/physicalResources.js | 7 +++---
2 files changed, 24 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b2f68e8/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 160015a..9f0000e 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -16,12 +16,14 @@
// under the License.
package com.cloud.server;
+import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
+import java.net.URLDecoder;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;
@@ -2808,18 +2810,32 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
}
- if (cmd.getPrivateKey() != null && !_ksMgr.validateCertificate(cmd.getCertificate(), cmd.getPrivateKey(), cmd.getDomainSuffix())) {
+ String certificate = cmd.getCertificate();
+ String key = cmd.getPrivateKey();
+ try {
+ if (certificate != null)
+ certificate = URLDecoder.decode(certificate, "UTF-8");
+ if (key != null)
+ key = URLDecoder.decode(key, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ } finally {
+ }
+
+ if (cmd.getPrivateKey() != null && !_ksMgr.validateCertificate(certificate, key, cmd.getDomainSuffix())) {
throw new InvalidParameterValueException("Failed to pass certificate validation check");
}
if (cmd.getPrivateKey() != null) {
- _ksMgr.saveCertificate(ConsoleProxyManager.CERTIFICATE_NAME, cmd.getCertificate(), cmd.getPrivateKey(), cmd.getDomainSuffix());
+ _ksMgr.saveCertificate(ConsoleProxyManager.CERTIFICATE_NAME, certificate, key, cmd.getDomainSuffix());
} else {
- _ksMgr.saveCertificate(cmd.getAlias(), cmd.getCertificate(), cmd.getCertIndex(), cmd.getDomainSuffix());
+ _ksMgr.saveCertificate(cmd.getAlias(), certificate, cmd.getCertIndex(), cmd.getDomainSuffix());
}
_consoleProxyMgr.setManagementState(ConsoleProxyManagementState.ResetSuspending);
- return "Certificate has been updated, we will stop all running console proxy VMs to propagate the new certificate, please give a few minutes for console access service to be up again";
+ List<SecondaryStorageVmVO> alreadyRunning = _secStorageVmDao.getSecStorageVmListInStates(null, State.Running, State.Migrating, State.Starting);
+ for (SecondaryStorageVmVO ssVmVm : alreadyRunning)
+ _secStorageVmMgr.rebootSecStorageVm(ssVmVm.getId());
+ return "Certificate has been updated, we will stop all running console proxy VMs and secondary storage VMs to propagate the new certificate, please give a few minutes for console access service to be up again";
}
@Override
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7b2f68e8/ui/scripts/ui-custom/physicalResources.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui-custom/physicalResources.js b/ui/scripts/ui-custom/physicalResources.js
index 69c0295..cb1f8de 100644
--- a/ui/scripts/ui-custom/physicalResources.js
+++ b/ui/scripts/ui-custom/physicalResources.js
@@ -77,10 +77,11 @@
var $loading = $('<div>').addClass('loading-overlay');
$('.system-dashboard-view:visible').prepend($loading);
$.ajax({
+ type: "POST",
url: createURL('uploadCustomCertificate'),
data: {
- certificate: args.data.certificate,
- privatekey: args.data.privatekey,
+ certificate: encodeURIComponent(args.data.certificate),
+ privatekey: encodeURIComponent(args.data.privatekey),
domainsuffix: args.data.domainsuffix
},
dataType: 'json',
@@ -130,4 +131,4 @@
return resourceChart(args);
};
};
-}(cloudStack, jQuery));
\ No newline at end of file
+}(cloudStack, jQuery));