You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2018/08/21 14:35:41 UTC

ignite git commit: IGNITE-6167: Add SslContextFactory.protocols and SslContextFactory.cipherSuites properties to control allowed encryption algorithms. This closes #4440. This closes #4582.

Repository: ignite
Updated Branches:
  refs/heads/master c58ed659b -> a09b2c057


IGNITE-6167: Add SslContextFactory.protocols and SslContextFactory.cipherSuites properties to control allowed encryption algorithms. This closes #4440. This closes #4582.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a09b2c05
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a09b2c05
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a09b2c05

Branch: refs/heads/master
Commit: a09b2c0579c96c7ab5b8abfe8fde0149041ff70e
Parents: c58ed65
Author: Mikhail Cherkasov <mi...@gmail.com>
Authored: Tue Aug 21 17:35:33 2018 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Aug 21 17:35:33 2018 +0300

----------------------------------------------------------------------
 .../ignite/ssl/DelegatingSSLContextSpi.java     | 103 ++++++
 .../apache/ignite/ssl/SSLContextWrapper.java    |  31 ++
 .../ssl/SSLServerSocketFactoryWrapper.java      |  80 +++++
 .../ignite/ssl/SSLSocketFactoryWrapper.java     | 113 +++++++
 .../apache/ignite/ssl/SslContextFactory.java    |  51 +++
 .../apache/ignite/client/SslParametersTest.java | 329 +++++++++++++++++++
 .../tcp/TcpDiscoverySslParametersTest.java      | 274 +++++++++++++++
 .../ignite/testframework/GridTestUtils.java     |  25 +-
 .../IgniteSpiDiscoverySelfTestSuite.java        |   6 +-
 .../apache/ignite/client/ClientTestSuite.java   |   3 +-
 10 files changed, 1001 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a09b2c05/modules/core/src/main/java/org/apache/ignite/ssl/DelegatingSSLContextSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/ssl/DelegatingSSLContextSpi.java b/modules/core/src/main/java/org/apache/ignite/ssl/DelegatingSSLContextSpi.java
new file mode 100644
index 0000000..d8621f2
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/ssl/DelegatingSSLContextSpi.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ssl;
+
+import java.security.KeyManagementException;
+import java.security.SecureRandom;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLContextSpi;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSessionContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+
+/** */
+class DelegatingSSLContextSpi extends SSLContextSpi {
+
+    /** */
+    private final SSLContext delegate;
+
+    /** */
+    private final SSLParameters parameters;
+
+    /** */
+    DelegatingSSLContextSpi(SSLContext delegate, SSLParameters parameters) {
+        this.delegate = delegate;
+        this.parameters = parameters;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void engineInit(KeyManager[] keyManagers, TrustManager[] trustManagers,
+        SecureRandom secureRandom) throws KeyManagementException {
+        delegate.init(keyManagers, trustManagers, secureRandom);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected SSLSocketFactory engineGetSocketFactory() {
+        return new SSLSocketFactoryWrapper(delegate.getSocketFactory(), parameters);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected SSLServerSocketFactory engineGetServerSocketFactory() {
+        return new SSLServerSocketFactoryWrapper(delegate.getServerSocketFactory(),
+            parameters);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected SSLEngine engineCreateSSLEngine() {
+        final SSLEngine engine = delegate.createSSLEngine();
+
+        if (parameters != null)
+            engine.setSSLParameters(parameters);
+
+        return engine;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected SSLEngine engineCreateSSLEngine(String s, int i) {
+        final SSLEngine engine = delegate.createSSLEngine();
+
+        if (parameters != null)
+            engine.setSSLParameters(parameters);
+
+        return engine;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected SSLSessionContext engineGetServerSessionContext() {
+        return delegate.getServerSessionContext();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected SSLSessionContext engineGetClientSessionContext() {
+        return delegate.getClientSessionContext();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected SSLParameters engineGetDefaultSSLParameters() {
+        return delegate.getDefaultSSLParameters();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected SSLParameters engineGetSupportedSSLParameters() {
+        return delegate.getSupportedSSLParameters();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a09b2c05/modules/core/src/main/java/org/apache/ignite/ssl/SSLContextWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/ssl/SSLContextWrapper.java b/modules/core/src/main/java/org/apache/ignite/ssl/SSLContextWrapper.java
new file mode 100644
index 0000000..901d42b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/ssl/SSLContextWrapper.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ssl;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLParameters;
+
+/** */
+class SSLContextWrapper extends SSLContext {
+    /** */
+    SSLContextWrapper(SSLContext delegate, SSLParameters sslParameters) {
+        super(new DelegatingSSLContextSpi(delegate, sslParameters),
+            delegate.getProvider(),
+            delegate.getProtocol());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a09b2c05/modules/core/src/main/java/org/apache/ignite/ssl/SSLServerSocketFactoryWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/ssl/SSLServerSocketFactoryWrapper.java b/modules/core/src/main/java/org/apache/ignite/ssl/SSLServerSocketFactoryWrapper.java
new file mode 100644
index 0000000..ad80f3c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/ssl/SSLServerSocketFactoryWrapper.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ssl;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+
+/** */
+class SSLServerSocketFactoryWrapper extends SSLServerSocketFactory {
+
+    /** */
+    private final SSLServerSocketFactory delegate;
+    /** */
+    private final SSLParameters parameters;
+
+    /** */
+    SSLServerSocketFactoryWrapper(SSLServerSocketFactory delegate, SSLParameters parameters) {
+        this.delegate = delegate;
+        this.parameters = parameters;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String[] getDefaultCipherSuites() {
+        return delegate.getDefaultCipherSuites();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String[] getSupportedCipherSuites() {
+        return delegate.getSupportedCipherSuites();
+    }
+
+    /** {@inheritDoc} */
+    @Override public ServerSocket createServerSocket(int port) throws IOException {
+        SSLServerSocket srvSock = (SSLServerSocket)delegate.createServerSocket(port);
+
+        if (parameters != null)
+            srvSock.setSSLParameters(parameters);
+
+        return srvSock;
+    }
+
+    /** {@inheritDoc} */
+    @Override public ServerSocket createServerSocket(int port, int backlog) throws IOException {
+        SSLServerSocket srvSock = (SSLServerSocket)delegate.createServerSocket(port, backlog);
+
+        srvSock.setSSLParameters(parameters);
+
+        return srvSock;
+    }
+
+    /** {@inheritDoc} */
+    @Override public ServerSocket createServerSocket(int port, int backlog, InetAddress locAddr) throws IOException {
+        SSLServerSocket srvSock = (SSLServerSocket)delegate.createServerSocket(port, backlog, locAddr);
+
+        if (parameters != null)
+            srvSock.setSSLParameters(parameters);
+
+        return srvSock;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a09b2c05/modules/core/src/main/java/org/apache/ignite/ssl/SSLSocketFactoryWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/ssl/SSLSocketFactoryWrapper.java b/modules/core/src/main/java/org/apache/ignite/ssl/SSLSocketFactoryWrapper.java
new file mode 100644
index 0000000..bfe6d0d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/ssl/SSLSocketFactoryWrapper.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.ssl;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+/** */
+class SSLSocketFactoryWrapper extends SSLSocketFactory {
+
+    /** */
+    private final SSLSocketFactory delegate;
+
+    /** */
+    private final SSLParameters parameters;
+
+    /** */
+    SSLSocketFactoryWrapper(SSLSocketFactory delegate, SSLParameters parameters) {
+        this.delegate = delegate;
+        this.parameters = parameters;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String[] getDefaultCipherSuites() {
+        return delegate.getDefaultCipherSuites();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String[] getSupportedCipherSuites() {
+        return delegate.getSupportedCipherSuites();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Socket createSocket() throws IOException {
+        SSLSocket sock = (SSLSocket)delegate.createSocket();
+
+        if (parameters != null)
+            sock.setSSLParameters(parameters);
+
+        return sock;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Socket createSocket(Socket sock, String host, int port, boolean autoClose) throws IOException {
+        SSLSocket sslSock = (SSLSocket)delegate.createSocket(sock, host, port, autoClose);
+
+        if (parameters != null)
+            sslSock.setSSLParameters(parameters);
+
+        return sock;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Socket createSocket(String host, int port) throws IOException {
+        SSLSocket sock = (SSLSocket)delegate.createSocket(host, port);
+
+        if (parameters != null)
+            sock.setSSLParameters(parameters);
+
+        return sock;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Socket createSocket(String host, int port, InetAddress locAddr, int locPort) throws IOException {
+        SSLSocket sock = (SSLSocket)delegate.createSocket(host, port, locAddr, locPort);
+
+        if (parameters != null)
+            sock.setSSLParameters(parameters);
+
+        return sock;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Socket createSocket(InetAddress addr, int port) throws IOException {
+        SSLSocket sock = (SSLSocket)delegate.createSocket(addr, port);
+
+        if (parameters != null)
+            sock.setSSLParameters(parameters);
+
+        return sock;
+    }
+
+    /** {@inheritDoc} */
+    @Override public Socket createSocket(InetAddress addr, int port, InetAddress locAddr,
+        int locPort) throws IOException {
+        SSLSocket sock = (SSLSocket)delegate.createSocket(addr, port, locAddr, locPort);
+
+        if (parameters != null)
+            sock.setSSLParameters(parameters);
+
+        return sock;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a09b2c05/modules/core/src/main/java/org/apache/ignite/ssl/SslContextFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/ssl/SslContextFactory.java b/modules/core/src/main/java/org/apache/ignite/ssl/SslContextFactory.java
index 06edd70..c514b0f 100644
--- a/modules/core/src/main/java/org/apache/ignite/ssl/SslContextFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/ssl/SslContextFactory.java
@@ -30,6 +30,7 @@ import javax.cache.configuration.Factory;
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLParameters;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 import javax.net.ssl.X509TrustManager;
@@ -89,6 +90,12 @@ public class SslContextFactory implements Factory<SSLContext> {
     /** Trust managers. */
     private TrustManager[] trustMgrs;
 
+    /** Enabled cipher suites. */
+    private String[] cipherSuites;
+
+    /** Enabled cipher suites. */
+    private String[] protocols;
+
     /**
      * Gets key store type used for context creation.
      *
@@ -281,6 +288,38 @@ public class SslContextFactory implements Factory<SSLContext> {
     }
 
     /**
+     * Sets enabled cipher suites.
+     * @param cipherSuites enabled cipher suites.
+     */
+    public void setCipherSuites(String... cipherSuites) {
+        this.cipherSuites = cipherSuites;
+    }
+
+    /**
+     * Gets enabled cipher suites
+     * @return enabled cipher suites
+     */
+    public String[] getCipherSuites() {
+        return cipherSuites;
+    }
+
+    /**
+     * Gets enabled cipher suites
+     * @return enabled cipher suites
+     */
+    public String[] getProtocols() {
+        return protocols;
+    }
+
+    /**
+     * Sets enabled protocols.
+     * @param protocols enabled protocols.
+     */
+    public void setProtocols(String... protocols) {
+        this.protocols = protocols;
+    }
+
+    /**
      * Creates SSL context based on factory settings.
      *
      * @return Initialized SSL context.
@@ -310,6 +349,18 @@ public class SslContextFactory implements Factory<SSLContext> {
 
             SSLContext ctx = SSLContext.getInstance(proto);
 
+            if (cipherSuites != null || protocols != null) {
+                SSLParameters sslParameters = new SSLParameters();
+
+                if (cipherSuites != null)
+                    sslParameters.setCipherSuites(cipherSuites);
+
+                if (protocols != null)
+                    sslParameters.setProtocols(protocols);
+
+                ctx = new SSLContextWrapper(ctx, sslParameters);
+            }
+
             ctx.init(keyMgrFactory.getKeyManagers(), mgrs, null);
 
             return ctx;

http://git-wip-us.apache.org/repos/asf/ignite/blob/a09b2c05/modules/core/src/test/java/org/apache/ignite/client/SslParametersTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/client/SslParametersTest.java b/modules/core/src/test/java/org/apache/ignite/client/SslParametersTest.java
new file mode 100644
index 0000000..7ac6108
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/client/SslParametersTest.java
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.client;
+
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.configuration.ClientConnectorConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.ssl.SslContextFactory;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Tests cases when node connects to cluster with different set of cipher suites.
+ */
+public class SslParametersTest extends GridCommonAbstractTest {
+
+    public static final String TEST_CACHE_NAME = "TEST";
+    /** */
+    private volatile String[] cipherSuites;
+
+    /** */
+    private volatile String[] protocols;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setClientConnectorConfiguration(new ClientConnectorConfiguration()
+            .setSslEnabled(true)
+            .setUseIgniteSslContextFactory(true));
+
+        cfg.setSslContextFactory(createSslFactory());
+
+        CacheConfiguration ccfg = new CacheConfiguration(TEST_CACHE_NAME);
+
+        cfg.setCacheConfiguration(ccfg);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    protected ClientConfiguration getClientConfiguration() throws Exception {
+        ClientConfiguration cfg = new ClientConfiguration();
+
+        cfg.setAddresses("127.0.0.1:10800");
+
+        cfg.setSslMode(SslMode.REQUIRED);
+
+        cfg.setSslContextFactory(createSslFactory());
+
+        return cfg;
+    }
+
+    @NotNull private SslContextFactory createSslFactory() {
+        SslContextFactory factory = (SslContextFactory)GridTestUtils.sslTrustedFactory(
+            "node01", "trustone");
+
+        factory.setCipherSuites(cipherSuites);
+        factory.setProtocols(protocols);
+
+        return factory;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        protocols = null;
+        cipherSuites = null;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSameCipherSuite() throws Exception {
+        cipherSuites = new String[] {
+            "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
+            "TLS_RSA_WITH_AES_128_GCM_SHA256",
+            "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+        };
+
+        startGrid();
+
+        checkSuccessfulClientStart(
+            new String[][] {
+                new String[] {
+                    "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
+                    "TLS_RSA_WITH_AES_128_GCM_SHA256",
+                    "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+                }
+            },
+            null
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOneCommonCipherSuite() throws Exception {
+        cipherSuites = new String[] {
+            "TLS_RSA_WITH_AES_128_GCM_SHA256",
+            "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+        };
+
+        startGrid();
+        
+        checkSuccessfulClientStart(
+            new String[][] {
+                new String[] {
+                    "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
+                    "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+                }
+            },
+            null
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNoCommonCipherSuite() throws Exception {
+        cipherSuites = new String[] {
+            "TLS_RSA_WITH_AES_128_GCM_SHA256"
+        };
+
+        startGrid();
+        
+        checkClientStartFailure(
+            new String[][] {
+                new String[] {
+                    "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
+                    "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+                }
+            },
+            null
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNonExistentCipherSuite() throws Exception {
+        cipherSuites = new String[] {
+            "TLS_RSA_WITH_AES_128_GCM_SHA256"
+        };
+
+        startGrid();
+        
+        checkClientStartFailure(
+            new String[][] {
+                new String[] {
+                    "TLC_FAKE_CIPHER",
+                    "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+                }
+            },
+            null,
+            IllegalArgumentException.class,
+            "Unsupported ciphersuite"
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNoCommonProtocols() throws Exception {
+        protocols = new String[] {
+            "TLSv1.1",
+            "SSLv3"
+        };
+
+        startGrid();
+
+        checkClientStartFailure(
+            null,
+            new String[][] {
+                new String[] {
+                    "TLSv1",
+                    "TLSv1.2",
+                }
+            }
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNonExistentProtocol() throws Exception {
+        protocols = new String[] {
+            "SSLv3"
+        };
+
+        startGrid();
+
+        checkClientStartFailure(
+            null,
+            new String[][] {
+                new String[] {
+                    "SSLv3",
+                    "SSLvDoesNotExist"
+                }
+            },
+            IllegalArgumentException.class,
+            "SSLvDoesNotExist"
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSameProtocols() throws Exception {
+        protocols = new String[] {
+            "TLSv1.1",
+            "TLSv1.2",
+        };
+
+        startGrid();
+
+        checkSuccessfulClientStart(null,
+            new String[][] {
+                new String[] {
+                    "TLSv1.1",
+                    "TLSv1.2",
+                }
+            }
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOneCommonProtocol() throws Exception {
+        protocols = new String[] {
+            "TLSv1",
+            "TLSv1.1",
+            "TLSv1.2"
+        };
+
+        startGrid();
+
+        checkSuccessfulClientStart(null,
+            new String[][] {
+                new String[] {
+                    "TLSv1.1",
+                    "SSLv3"
+                }
+            }
+        );
+    }
+
+    /**
+     * @param cipherSuites list of cipher suites
+     * @param protocols list of protocols
+     * @throws Exception If failed.
+     */
+    private void checkSuccessfulClientStart(String[][] cipherSuites, String[][] protocols) throws Exception {
+        int n = Math.max(
+            cipherSuites != null ? cipherSuites.length : 0,
+            protocols != null ? protocols.length : 0);
+
+        for (int i = 0; i < n; i++) {
+            this.cipherSuites = cipherSuites != null && i < cipherSuites.length ? cipherSuites[i] : null;
+            this.protocols = protocols != null && i < protocols.length ? protocols[i] : null;
+
+            IgniteClient client = Ignition.startClient(getClientConfiguration());
+
+            client.getOrCreateCache(TEST_CACHE_NAME);
+
+            client.close();
+        }
+    }
+
+    /**
+     * @param cipherSuites list of cipher suites
+     * @param protocols list of protocols
+     * @throws Exception If failed.
+     */
+    private void checkClientStartFailure(String[][] cipherSuites, String[][] protocols) throws Exception {
+        checkClientStartFailure(cipherSuites, protocols, ClientConnectionException.class, "Ignite cluster is unavailable");
+    }
+
+    /**
+     * @param cipherSuites list of cipher suites
+     * @param protocols list of protocols
+     * @param ex expected exception class
+     * @param msg exception message
+     * @throws Exception If failed.
+     */
+    private void checkClientStartFailure(String[][] cipherSuites, String[][] protocols, Class<? extends Throwable> ex, String msg) throws Exception {
+        int n = Math.max(
+            cipherSuites != null ? cipherSuites.length : 0,
+            protocols != null ? protocols.length : 0);
+
+        for (int i = 0; i < n; i++) {
+            this.cipherSuites = cipherSuites != null && i < cipherSuites.length ? cipherSuites[i] : null;
+            this.protocols = protocols != null && i < protocols.length ? protocols[i] : null;
+
+            int finalI = i;
+
+            GridTestUtils.assertThrows(null, new Callable<Object>() {
+                @Override public Object call() throws Exception {
+                    Ignition.startClient(getClientConfiguration());
+
+                    return null;
+                }
+            }, ex, msg);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a09b2c05/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslParametersTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslParametersTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslParametersTest.java
new file mode 100644
index 0000000..f2fc278
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySslParametersTest.java
@@ -0,0 +1,274 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.spi.discovery.tcp;
+
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.ssl.SslContextFactory;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Tests cases when node connects to cluster with different set of cipher suites.
+ */
+public class TcpDiscoverySslParametersTest extends GridCommonAbstractTest {
+
+    /** */
+    private volatile String[] cipherSuites;
+
+    /** */
+    private volatile String[] protocols;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        SslContextFactory factory = (SslContextFactory)GridTestUtils.sslTrustedFactory(
+            "node01", "trustone");
+
+        factory.setCipherSuites(cipherSuites);
+
+        factory.setProtocols(protocols);
+
+        cfg.setSslContextFactory(factory);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSameCipherSuite() throws Exception {
+        checkDiscoverySuccess(
+            new String[][] {
+                new String[] {
+                    "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
+                    "TLS_RSA_WITH_AES_128_GCM_SHA256",
+                    "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+                },
+                new String[] {
+                    "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
+                    "TLS_RSA_WITH_AES_128_GCM_SHA256",
+                    "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+                }
+            },
+            null
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOneCommonCipherSuite() throws Exception {
+        checkDiscoverySuccess(
+            new String[][] {
+                new String[] {
+                    "TLS_RSA_WITH_AES_128_GCM_SHA256",
+                    "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+                },
+                new String[] {
+                    "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
+                    "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+                }
+            },
+            null
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNoCommonCipherSuite() throws Exception {
+        checkDiscoveryFailure(
+            new String[][] {
+                new String[] {
+                    "TLS_RSA_WITH_AES_128_GCM_SHA256",
+                },
+                new String[] {
+                    "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
+                    "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+                }
+            },
+            null
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNonExistentCipherSuite() throws Exception {
+        checkDiscoveryFailure(
+            new String[][] {
+                new String[] {
+                    "TLS_RSA_WITH_AES_128_GCM_SHA256",
+                    "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+                },
+                new String[] {
+                    "TLC_FAKE_CIPHER",
+                    "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256"
+                }
+            },
+            null,
+            IgniteCheckedException.class,
+            "Unsupported ciphersuite"
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNoCommonProtocols() throws Exception {
+        checkDiscoveryFailure(
+            null,
+            new String[][] {
+                new String[] {
+                    "TLSv1.1",
+                    "SSLv3"
+                },
+                new String[] {
+                    "TLSv1",
+                    "TLSv1.2",
+                }
+            }
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNonExistentProtocol() throws Exception {
+        checkDiscoveryFailure(
+            null,
+            new String[][] {
+                new String[] {
+                    "SSLv3"
+                },
+                new String[] {
+                    "SSLv3",
+                    "SSLvDoesNotExist"
+                }
+            },
+            IgniteCheckedException.class,
+            "SSLvDoesNotExist"
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSameProtocols() throws Exception {
+        checkDiscoverySuccess(null,
+            new String[][] {
+                new String[] {
+                    "TLSv1.1",
+                    "TLSv1.2",
+                },
+                new String[] {
+                    "TLSv1.1",
+                    "TLSv1.2",
+                }
+            }
+        );
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOneCommonProtocol() throws Exception {
+        checkDiscoverySuccess(null,
+            new String[][] {
+                new String[] {
+                    "TLSv1",
+                    "TLSv1.1",
+                    "TLSv1.2",
+                },
+                new String[] {
+                    "TLSv1.1",
+                    "SSLv3"
+                }
+            }
+        );
+    }
+
+    /**
+     * @param cipherSuites list of cipher suites
+     * @param protocols list of protocols
+     * @throws Exception If failed.
+     */
+    private void checkDiscoverySuccess(String[][] cipherSuites, String[][] protocols) throws Exception {
+        int n = Math.max(
+            cipherSuites != null ? cipherSuites.length : 0,
+            protocols != null ? protocols.length : 0);
+
+        for (int i = 0; i < n; i++) {
+            this.cipherSuites = cipherSuites != null && i < cipherSuites.length ? cipherSuites[i] : null;
+            this.protocols = protocols != null && i < protocols.length ? protocols[i] : null;
+
+            startGrid(i);
+        }
+    }
+
+    /**
+     * @param cipherSuites list of cipher suites
+     * @param protocols list of protocols
+     * @throws Exception If failed.
+     */
+    private void checkDiscoveryFailure(String[][] cipherSuites, String[][] protocols) throws Exception {
+        checkDiscoveryFailure(cipherSuites, protocols, IgniteCheckedException.class, "Unable to establish secure connection.");
+    }
+
+    /**
+     * @param cipherSuites list of cipher suites
+     * @param protocols list of protocols
+     * @param ex expected exception class
+     * @param msg exception message
+     * @throws Exception If failed.
+     */
+    private void checkDiscoveryFailure(String[][] cipherSuites, String[][] protocols, Class<? extends Throwable> ex, String msg) throws Exception {
+        this.cipherSuites = cipherSuites != null ? cipherSuites[0] : null;
+        this.protocols = protocols != null ? protocols[0] : null;
+
+        startGrid(0);
+
+        int n = Math.max(
+            cipherSuites != null ? cipherSuites.length : 0,
+            protocols != null ? protocols.length : 0);
+
+        for (int i = 1; i < n; i++) {
+            this.cipherSuites = cipherSuites != null && i < cipherSuites.length ? cipherSuites[i] : null;
+            this.protocols = protocols != null && i < protocols.length ? protocols[i] : null;
+
+            int finalI = i;
+
+            GridTestUtils.assertThrows(null, new Callable<Object>() {
+                @Override public Object call() throws Exception {
+                    startGrid(finalI);
+
+                    return null;
+                }
+            }, ex, msg);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/a09b2c05/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
index 9390d6b..786d0e0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
@@ -1665,7 +1665,7 @@ public final class GridTestUtils {
     public static SSLContext sslContext() throws GeneralSecurityException, IOException {
         SSLContext ctx = SSLContext.getInstance("TLS");
 
-        char[] storePass = GridTestProperties.getProperty("ssl.keystore.password").toCharArray();
+        char[] storePass = keyStorePassword().toCharArray();
 
         KeyManagerFactory keyMgrFactory = KeyManagerFactory.getInstance("SunX509");
 
@@ -1692,7 +1692,7 @@ public final class GridTestUtils {
 
         factory.setKeyStoreFilePath(
             U.resolveIgnitePath(GridTestProperties.getProperty("ssl.keystore.path")).getAbsolutePath());
-        factory.setKeyStorePassword(GridTestProperties.getProperty("ssl.keystore.password").toCharArray());
+        factory.setKeyStorePassword(keyStorePassword().toCharArray());
 
         factory.setTrustManagers(GridSslBasicContextFactory.getDisabledTrustManager());
 
@@ -1710,7 +1710,7 @@ public final class GridTestUtils {
 
         factory.setKeyStoreFilePath(
             U.resolveIgnitePath(GridTestProperties.getProperty("ssl.keystore.path")).getAbsolutePath());
-        factory.setKeyStorePassword(GridTestProperties.getProperty("ssl.keystore.password").toCharArray());
+        factory.setKeyStorePassword(keyStorePassword().toCharArray());
 
         factory.setTrustManagers(SslContextFactory.getDisabledTrustManager());
 
@@ -1727,16 +1727,23 @@ public final class GridTestUtils {
     public static Factory<SSLContext> sslTrustedFactory(String keyStore, String trustStore) {
         SslContextFactory factory = new SslContextFactory();
 
-        factory.setKeyStoreFilePath(U.resolveIgnitePath(GridTestProperties.getProperty(
-            "ssl.keystore." + keyStore + ".path")).getAbsolutePath());
-        factory.setKeyStorePassword(GridTestProperties.getProperty("ssl.keystore.password").toCharArray());
-        factory.setTrustStoreFilePath(U.resolveIgnitePath(GridTestProperties.getProperty(
-            "ssl.keystore." + trustStore + ".path")).getAbsolutePath());
-        factory.setTrustStorePassword(GridTestProperties.getProperty("ssl.keystore.password").toCharArray());
+        factory.setKeyStoreFilePath(keyStorePath(keyStore));
+        factory.setKeyStorePassword(keyStorePassword().toCharArray());
+        factory.setTrustStoreFilePath(keyStorePath(trustStore));
+        factory.setTrustStorePassword(keyStorePassword().toCharArray());
 
         return factory;
     }
 
+    public static String keyStorePassword() {
+        return GridTestProperties.getProperty("ssl.keystore.password");
+    }
+
+    @NotNull public static String keyStorePath(String keyStore) {
+        return U.resolveIgnitePath(GridTestProperties.getProperty(
+            "ssl.keystore." + keyStore + ".path")).getAbsolutePath();
+    }
+
     /**
      * @param o1 Object 1.
      * @param o2 Object 2.

http://git-wip-us.apache.org/repos/asf/ignite/blob/a09b2c05/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
index cb284cf..39d5421 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
@@ -31,7 +31,6 @@ import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoverySpiFailureTimeoutSe
 import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoverySpiMulticastTest;
 import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoverySpiSelfTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoveryClientSuspensionSelfTest;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoveryConcurrentStartTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoveryMarshallerCheckSelfTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoveryMultiThreadedTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoveryNodeAttributesUpdateOnReconnectTest;
@@ -45,12 +44,10 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySnapshotHistoryTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiConfigSelfTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiFailureTimeoutSelfTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiMBeanTest;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiRandomStartStopTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiReconnectDelayTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiSelfTest;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiSslSelfTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiStartStopSelfTest;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpiWildcardSelfTest;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySslParametersTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySslSecuredUnsecuredTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySslSelfTest;
 import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySslTrustedSelfTest;
@@ -131,6 +128,7 @@ public class IgniteSpiDiscoverySelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(TcpDiscoverySslTrustedSelfTest.class));
         suite.addTest(new TestSuite(TcpDiscoverySslSecuredUnsecuredTest.class));
         suite.addTest(new TestSuite(TcpDiscoverySslTrustedUntrustedTest.class));
+        suite.addTest(new TestSuite(TcpDiscoverySslParametersTest.class));
 
         // Disco cache reuse.
         suite.addTest(new TestSuite(IgniteDiscoveryCacheReuseSelfTest.class));

http://git-wip-us.apache.org/repos/asf/ignite/blob/a09b2c05/modules/indexing/src/test/java/org/apache/ignite/client/ClientTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/client/ClientTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/client/ClientTestSuite.java
index 3fb243c..623a19e 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/client/ClientTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/client/ClientTestSuite.java
@@ -33,7 +33,8 @@ import org.junit.runners.Suite;
     ReliabilityTest.class,
     SecurityTest.class,
     FunctionalQueryTest.class,
-    IgniteBinaryQueryTest.class
+    IgniteBinaryQueryTest.class,
+    SslParametersTest.class
 })
 public class ClientTestSuite {
     // No-op.