Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/java/com/cloud/info/ConsoleProxyInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public ConsoleProxyInfo(boolean sslEnabled, String proxyIpAddress, int port, int
}

} else {
proxyImageUrl = "http://" + proxyAddress;
proxyImageUrl = "//" + proxyAddress;
if (proxyUrlPort != 80) {
proxyImageUrl += ":" + proxyUrlPort;
}
Expand Down
10 changes: 5 additions & 5 deletions core/src/test/java/com/cloud/info/ConsoleProxyInfoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

package com.cloud.info;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class ConsoleProxyInfoTest {

@Test
Expand All @@ -35,7 +35,7 @@ public void testGetProxyImageUrlHttps() {
public void testGetProxyImageUrlHttp() {
ConsoleProxyInfo cpi = new ConsoleProxyInfo(false, "10.10.10.10", 80, 80 , "console.example.com");
String url = cpi.getProxyImageUrl();
assertEquals("http://console.example.com", url);
assertEquals("//console.example.com", url);
}
@Test
public void testGetProxyImageUrlWildcardHttps() {
Expand All @@ -47,13 +47,13 @@ public void testGetProxyImageUrlWildcardHttps() {
public void testGetProxyImageUrlWildcardHttp() {
ConsoleProxyInfo cpi = new ConsoleProxyInfo(false, "1.2.3.4", 80, 8888 , "*.example.com");
String url = cpi.getProxyImageUrl();
assertEquals("http://1-2-3-4.example.com:8888", url);
assertEquals("//1-2-3-4.example.com:8888", url);
}
@Test
public void testGetProxyImageUrlIpHttp() {
ConsoleProxyInfo cpi = new ConsoleProxyInfo(false, "1.2.3.4", 80, 8888, "");
String url = cpi.getProxyImageUrl();
assertEquals("http://1.2.3.4:8888", url);
assertEquals("//1.2.3.4:8888", url);
}
@Test
public void testGetProxyImageUrlIpHttps() {
Expand Down
20 changes: 11 additions & 9 deletions server/src/main/java/com/cloud/consoleproxy/AgentHookBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@
import java.security.SecureRandom;
import java.util.Date;

import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.framework.security.keys.KeysManager;
import org.apache.cloudstack.framework.security.keystore.KeystoreManager;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;

import com.cloud.agent.AgentManager;
import com.cloud.agent.api.AgentControlAnswer;
Expand All @@ -54,6 +51,8 @@
import com.cloud.utils.Ternary;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.dao.VMInstanceDao;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
* Utility class to manage interactions with agent-based console access
Expand Down Expand Up @@ -198,12 +197,15 @@ public void startAgentHttpHandlerInVM(StartupProxyCommand startupCmd) {
String storePassword = Base64.encodeBase64String(randomBytes);

byte[] ksBits = null;

String consoleProxyUrlDomain = _configDao.getValue(Config.ConsoleProxyUrlDomain.key());
if (consoleProxyUrlDomain == null || consoleProxyUrlDomain.isEmpty()) {
s_logger.debug("SSL is disabled for console proxy based on global config, skip loading certificates");
} else {
String consoleProxySslEnabled = _configDao.getValue("consoleproxy.sslEnabled");
Comment thread
yadvr marked this conversation as resolved.
Resolved
if (!StringUtils.isEmpty(consoleProxyUrlDomain) && !StringUtils.isEmpty(consoleProxySslEnabled)
&& consoleProxySslEnabled.equalsIgnoreCase("true")) {
ksBits = _ksMgr.getKeystoreBits(ConsoleProxyManager.CERTIFICATE_NAME, ConsoleProxyManager.CERTIFICATE_NAME, storePassword);
//ks manager raises exception if ksBits are null, hence no need to explicltly handle the condition
} else {
s_logger.debug("SSL is disabled for console proxy. To enable SSL, please configure consoleproxy.sslEnabled and consoleproxy.url.domain global settings.");
}

cmd = new StartConsoleProxyAgentHttpHandlerCommand(ksBits, storePassword);
Expand Down