Skip to content

Commit debfcde

Browse files
committed
CLOUDSTACK-8160: use preferable protocols
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent ed69d58 commit debfcde

28 files changed

Lines changed: 162 additions & 52 deletions

File tree

client/tomcatconf/server-nonssl.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<!--
8383
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
8484
maxThreads="150" scheme="https" secure="true"
85-
clientAuth="false" sslProtocol="TLS"
85+
clientAuth="false" sslProtocol="TLS" sslEnabledProtocols="TLSv1.2,TLSv1.1"
8686
keystoreType="PKCS12"
8787
keystoreFile="conf\cloud-localhost.pk12"
8888
keystorePass="password"

client/tomcatconf/server-ssl.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<!--
8383
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
8484
maxThreads="150" scheme="https" secure="true"
85-
clientAuth="false" sslProtocol="TLS"
85+
clientAuth="false" sslProtocol="TLS" sslEnabledProtocols="TLSv1.2,TLSv1.1"
8686
keystoreType="PKCS12"
8787
keystoreFile="conf\cloud-localhost.pk12"
8888
keystorePass="password"

client/tomcatconf/server7-nonssl.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<!--
8383
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
8484
maxThreads="150" scheme="https" secure="true"
85-
clientAuth="false" sslProtocol="TLS"
85+
clientAuth="false" sslProtocol="TLS" sslEnabledProtocols="TLSv1.2,TLSv1.1"
8686
keystoreType="PKCS12"
8787
keystoreFile="conf\cloud-localhost.pk12"
8888
keystorePass="password"

client/tomcatconf/server7-ssl.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
<!--
8383
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
8484
maxThreads="150" scheme="https" secure="true"
85-
clientAuth="false" sslProtocol="TLS"
85+
clientAuth="false" sslProtocol="TLS" sslEnabledProtocols="TLSv1.2,TLSv1.1"
8686
keystoreType="PKCS12"
8787
keystoreFile="conf\cloud-localhost.pk12"
8888
keystorePass="password"

engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
5454
import org.apache.cloudstack.managed.context.ManagedContextTimerTask;
5555
import org.apache.cloudstack.utils.identity.ManagementServerNode;
56+
import org.apache.cloudstack.utils.security.SSLUtils;
5657

5758
import com.cloud.agent.AgentManager;
5859
import com.cloud.agent.api.Answer;
@@ -505,6 +506,7 @@ public SocketChannel connectToPeer(String peerName, SocketChannel prevCh) {
505506
SSLContext sslContext = Link.initSSLContext(true);
506507
sslEngine = sslContext.createSSLEngine(ip, Port.value());
507508
sslEngine.setUseClientMode(true);
509+
sslEngine.setEnabledProtocols(SSLUtils.getSupportedProtocols(sslEngine.getEnabledProtocols()));
508510

509511
Link.doHandshake(ch, sslEngine, true);
510512
s_logger.info("SSL: Handshake done");

plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus {
5959
private static Integer port;
6060
private static String username;
6161
private static String password;
62+
private static String secureProtocol = "TLSv1.2";
6263

6364
public synchronized static void setVirtualHost(String virtualHost) {
6465
RabbitMQEventBus.virtualHost = virtualHost;
@@ -153,6 +154,10 @@ public void setPort(Integer port) {
153154
RabbitMQEventBus.port = port;
154155
}
155156

157+
public void setSecureProtocol(String protocol) {
158+
RabbitMQEventBus.secureProtocol = protocol;
159+
}
160+
156161
@Override
157162
public void setName(String name) {
158163
this.name = name;
@@ -373,7 +378,7 @@ private synchronized Connection createConnection() throws Exception {
373378
}
374379

375380
if (useSsl != null && !useSsl.isEmpty() && useSsl.equalsIgnoreCase("true")) {
376-
factory.useSslProtocol();
381+
factory.useSslProtocol(this.secureProtocol);
377382
}
378383
Connection connection = factory.newConnection();
379384
connection.addShutdownListener(disconnectHandler);

plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerConnectionPool.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import org.apache.xmlrpc.XmlRpcException;
3737
import org.apache.xmlrpc.client.XmlRpcClientException;
3838

39+
import org.apache.cloudstack.utils.security.SSLUtils;
40+
3941
import com.xensource.xenapi.APIVersion;
4042
import com.xensource.xenapi.Connection;
4143
import com.xensource.xenapi.Host;
@@ -82,7 +84,7 @@ public class XenServerConnectionPool {
8284
javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
8385
javax.net.ssl.TrustManager tm = new TrustAllManager();
8486
trustAllCerts[0] = tm;
85-
javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("TLS");
87+
javax.net.ssl.SSLContext sc = SSLUtils.getSSLContext();
8688
sc.init(null, trustAllCerts, null);
8789
javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
8890
HostnameVerifier hv = new HostnameVerifier() {

plugins/network-elements/opendaylight/src/main/java/org/apache/cloudstack/network/opendaylight/api/NeutronRestApi.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.apache.cloudstack.network.opendaylight.api;
2121

22+
import org.apache.cloudstack.utils.security.SSLUtils;
2223
import java.io.IOException;
2324
import java.lang.reflect.Constructor;
2425
import java.lang.reflect.InvocationTargetException;
@@ -33,6 +34,7 @@
3334
import java.security.cert.X509Certificate;
3435

3536
import javax.net.ssl.SSLContext;
37+
import javax.net.ssl.SSLSocket;
3638
import javax.net.ssl.SSLSocketFactory;
3739
import javax.net.ssl.TrustManager;
3840
import javax.net.ssl.X509TrustManager;
@@ -175,7 +177,7 @@ public void checkServerTrusted(final X509Certificate[] certs, final String authT
175177

176178
try {
177179
// Install the all-trusting trust manager
178-
SSLContext sc = SSLContext.getInstance("SSL");
180+
SSLContext sc = SSLUtils.getSSLContext();
179181
sc.init(null, trustAllCerts, new java.security.SecureRandom());
180182
ssf = sc.getSocketFactory();
181183
} catch (KeyManagementException e) {
@@ -187,17 +189,23 @@ public void checkServerTrusted(final X509Certificate[] certs, final String authT
187189

188190
@Override
189191
public Socket createSocket(final String host, final int port) throws IOException {
190-
return ssf.createSocket(host, port);
192+
SSLSocket s = (SSLSocket) ssf.createSocket(host, port);
193+
s.setEnabledProtocols(SSLUtils.getSupportedProtocols(s.getEnabledProtocols()));
194+
return s;
191195
}
192196

193197
@Override
194198
public Socket createSocket(final String address, final int port, final InetAddress localAddress, final int localPort) throws IOException, UnknownHostException {
195-
return ssf.createSocket(address, port, localAddress, localPort);
199+
SSLSocket s = (SSLSocket) ssf.createSocket(address, port, localAddress, localPort);
200+
s.setEnabledProtocols(SSLUtils.getSupportedProtocols(s.getEnabledProtocols()));
201+
return s;
196202
}
197203

198204
@Override
199205
public Socket createSocket(final Socket socket, final String host, final int port, final boolean autoClose) throws IOException, UnknownHostException {
200-
return ssf.createSocket(socket, host, port, autoClose);
206+
SSLSocket s = (SSLSocket) ssf.createSocket(socket, host, port, autoClose);
207+
s.setEnabledProtocols(SSLUtils.getSupportedProtocols(s.getEnabledProtocols()));
208+
return s;
201209
}
202210

203211
@Override
@@ -207,7 +215,8 @@ public Socket createSocket(final String host, final int port, final InetAddress
207215
if (timeout == 0) {
208216
return createSocket(host, port, localAddress, localPort);
209217
} else {
210-
Socket s = ssf.createSocket();
218+
SSLSocket s = (SSLSocket) ssf.createSocket();
219+
s.setEnabledProtocols(SSLUtils.getSupportedProtocols(s.getEnabledProtocols()));
211220
s.bind(new InetSocketAddress(localAddress, localPort));
212221
s.connect(new InetSocketAddress(host, port), timeout);
213222
return s;

plugins/network-elements/palo-alto/src/com/cloud/network/utils/HttpClientWrapper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import javax.net.ssl.TrustManager;
2828
import javax.net.ssl.X509TrustManager;
2929

30+
import org.apache.cloudstack.utils.security.SSLUtils;
31+
3032
import org.apache.http.client.HttpClient;
3133
import org.apache.http.conn.ClientConnectionManager;
3234
import org.apache.http.conn.scheme.Scheme;
@@ -39,7 +41,7 @@ public class HttpClientWrapper {
3941

4042
public static HttpClient wrapClient(HttpClient base) {
4143
try {
42-
SSLContext ctx = SSLContext.getInstance("TLS");
44+
SSLContext ctx = SSLUtils.getSSLContext();
4345
X509TrustManager tm = new X509TrustManager() {
4446

4547
@Override

plugins/storage/volume/cloudbyte/src/org/apache/cloudstack/storage/datastore/util/ElastistorUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
import org.apache.http.auth.InvalidCredentialsException;
4141
import org.apache.log4j.Logger;
42+
import org.apache.cloudstack.utils.security.SSLUtils;
4243

4344
import com.google.gson.Gson;
4445
import com.google.gson.annotations.SerializedName;
@@ -1086,7 +1087,7 @@ public boolean verify(String urlHostName, SSLSession session) {
10861087

10871088
// Install the all-trusting trust manager
10881089
try {
1089-
SSLContext sc = SSLContext.getInstance("TLS");
1090+
SSLContext sc = SSLUtils.getSSLContext();
10901091
sc.init(null, trustAllCerts, new SecureRandom());
10911092
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
10921093
HttpsURLConnection.setDefaultHostnameVerifier(hv);

0 commit comments

Comments
 (0)