Skip to content

Commit 160b2e1

Browse files
author
Kelven Yang
committed
Finalize custom certficate support. hook with UI
1 parent 7255d68 commit 160b2e1

8 files changed

Lines changed: 28 additions & 14 deletions

File tree

api/src/com/cloud/api/commands/UploadCustomCertificateCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ public long getEntityOwnerId() {
8383
@Override
8484
public void execute(){
8585
String result = _mgr.uploadCertificate(this);
86-
if (result != null){
86+
if (result != null) {
8787
CustomCertificateResponse response = new CustomCertificateResponse();
8888
response.setResponseName(getCommandName());
89-
response.setUpdatedConsoleProxyIdList(result);
89+
response.setResultMessage(result);
9090
response.setObjectName("customcertificate");
9191
this.setResponseObject(response);
9292
} else {

api/src/com/cloud/api/response/CustomCertificateResponse.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@
2222

2323
public class CustomCertificateResponse extends BaseResponse {
2424

25-
@SerializedName("updatedconsoleproxyidlist") @Param(description="the list of the console proxy ids which were successfully updated")
26-
private String updatedConsoleProxyIdList;
25+
@SerializedName("message") @Param(description="message of the certificate upload operation")
26+
private String message;
2727

28-
public String getUpdatedConsoleProxyIdList() {
29-
return updatedConsoleProxyIdList;
28+
public String getResultMessage() {
29+
return message;
3030
}
3131

32-
public void setUpdatedConsoleProxyIdList(String updatedConsoleProxyIdList) {
33-
this.updatedConsoleProxyIdList = updatedConsoleProxyIdList;
32+
public void setResultMessage(String msg) {
33+
this.message = msg;
3434
}
35-
3635
}

client/WEB-INF/classes/resources/messages.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ label.bytes.received=Bytes Received
225225
label.bytes.sent=Bytes Sent
226226
label.cancel=Cancel
227227
label.certificate=Certificate
228+
label.privatekey=Private Key
229+
label.domain.suffix=DNS Domain Suffix
228230
label.character=Character
229231
label.cidr.account=CIDR or Account/Security Group
230232
label.close=Close

console-proxy/src/com/cloud/consoleproxy/ConsoleProxy.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*
1717
*/
18-
//
1918
package com.cloud.consoleproxy;
2019

2120
import java.io.File;

server/src/com/cloud/keystore/KeystoreManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public boolean validateCertificate(String certificate, String key, String domain
7676

7777
try {
7878
String ksPassword = "passwordForValidation";
79-
byte[] ksBits = CertificateHelper.buildAndSaveKeystore(domainSuffix, certificate, key, ksPassword);
79+
byte[] ksBits = CertificateHelper.buildAndSaveKeystore(domainSuffix, certificate, getKeyContent(key), ksPassword);
8080
KeyStore ks = CertificateHelper.loadKeystore(ksBits, ksPassword);
8181
if(ks != null)
8282
return true;

server/src/com/cloud/server/ManagementServerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4564,7 +4564,7 @@ public String uploadCertificate(UploadCustomCertificateCmd cmd) {
45644564
_ksMgr.saveCertificate(ConsoleProxyManager.CERTIFICATE_NAME, cmd.getCertificate(), cmd.getPrivateKey(), cmd.getDomainSuffix());
45654565

45664566
_consoleProxyMgr.setManagementState(ConsoleProxyManagementState.ResetSuspending);
4567-
return "Certificate has been updated, we will stop all running console proxy VMs for certificate propagation";
4567+
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";
45684568
}
45694569

45704570
@Override

ui/jsp/resource.jsp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,19 @@
644644
<ol>
645645
<li>
646646
<label><fmt:message key="label.certificate"/>:</label>
647-
<textarea class="text" name="update_cert" id="update_cert" style="height: 300px; width: 400px" />
647+
<textarea class="text" name="update_cert" id="update_cert" style="height: 200px; width: 400px" />
648648
<div id="update_cert_errormsg" class="dialog_formcontent_errormsg" style="display:none; width:300px" ></div>
649649
</li>
650+
<li>
651+
<label><fmt:message key="label.privatekey"/>:</label>
652+
<textarea class="text" name="update_privatekey" id="update_privatekey" style="height: 150px; width: 400px" />
653+
<div id="update_key_errormsg" class="dialog_formcontent_errormsg" style="display:none; width:300px" ></div>
654+
</li>
655+
<li>
656+
<label><fmt:message key="label.domain.suffix"/>:</label>
657+
<input class="text" name="update_domainsuffix" id="update_domainsuffix" style="width: 400px" />
658+
<div id="update_domainsuffix_errormsg" class="dialog_formcontent_errormsg" style="display:none; width:300px" ></div>
659+
</li>
650660
</ol>
651661
</form>
652662
</div>

ui/scripts/cloud.core.resource.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,14 +1596,18 @@ function initUpdateConsoleCertButton($midMenuAddLink2) {
15961596

15971597
var isValid = true;
15981598
isValid &= validateString("SSL Certificate", $thisDialog.find("#update_cert"), $thisDialog.find("#update_cert_errormsg"), false, 4096);
1599+
isValid &= validateString("Private Key for Certificate", $thisDialog.find("#update_privatekey"), $thisDialog.find("#update_key_errormsg"), false, 4096);
1600+
isValid &= validateString("DNS domain suffix that certificate has been signed for", $thisDialog.find("#update_domainsuffix"), $thisDialog.find("#update_domainsuffix_errormsg"), false, 4096);
15991601
if (!isValid) return;
16001602

16011603
$spinningWheel = $thisDialog.find("#spinning_wheel").show();
16021604

16031605
var cert = trim($thisDialog.find("#update_cert").val());
1606+
var privateKey = trim($thisDialog.find("#update_privatekey").val());
1607+
var domainSuffix = trim($thisDialog.find("#update_domainsuffix").val());
16041608

16051609
$.ajax({
1606-
data: createURL("command=uploadCustomCertificate&certificate="+todb(cert)),
1610+
data: createURL("command=uploadCustomCertificate&certificate="+todb(cert)+"&privatekey="+todb(privateKey)+"&domainsuffix="+todb(domainSuffix)),
16071611
dataType: "json",
16081612
success: function(json) {
16091613
var jobId = json.uploadcustomcertificateresponse.jobid;

0 commit comments

Comments
 (0)