You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2017/10/04 04:23:52 UTC

[cloudstack] branch master updated: CLOUDSTACK-9993: With auth strictness stop SSL handshake for rogue clients (#2278)

This is an automated email from the ASF dual-hosted git repository.

bhaisaab pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/master by this push:
     new 0dfdbe0  CLOUDSTACK-9993: With auth strictness stop SSL handshake for rogue clients (#2278)
0dfdbe0 is described below

commit 0dfdbe064c380b23ab991cca001e24c583cb0452
Author: Rohit Yadav <bh...@apache.org>
AuthorDate: Wed Oct 4 09:53:49 2017 +0530

    CLOUDSTACK-9993: With auth strictness stop SSL handshake for rogue clients (#2278)
    
    When auth strictness is set to true, terminate SSH handshake for clients
    that do not present valid certificates.
    
    This uses the `setNeedClientAuth`, where if the option is set and the
    client chooses not to provide authentication information about itself,
    the negotiations will stop and the engine will begin its closure
    procedure:
    https://docs.oracle.com/javase/7/docs/api/javax/net/ssl/SSLEngine.html#setNeedClientAuth(boolean)
    
    During systemvm reboot, the conf folder is removed and certificate
    re-setup is not done. This may cause the agent to not connect, this
    fixes the case by backing up and restoring keystore and other config
    files when re-patching is done after rebooting of a systemvm (cpvm, ssvm).
    
    Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
---
 .../src/org/apache/cloudstack/ca/provider/RootCAProvider.java |  2 +-
 .../org/apache/cloudstack/ca/provider/RootCAProviderTest.java |  4 ++--
 systemvm/patches/debian/config/opt/cloud/bin/patchsystemvm.sh | 11 +++++++++++
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/plugins/ca/root-ca/src/org/apache/cloudstack/ca/provider/RootCAProvider.java b/plugins/ca/root-ca/src/org/apache/cloudstack/ca/provider/RootCAProvider.java
index 1f39853..f21cae3 100644
--- a/plugins/ca/root-ca/src/org/apache/cloudstack/ca/provider/RootCAProvider.java
+++ b/plugins/ca/root-ca/src/org/apache/cloudstack/ca/provider/RootCAProvider.java
@@ -249,7 +249,7 @@ public final class RootCAProvider extends AdapterBase implements CAProvider, Con
         TrustManager[] tms = new TrustManager[]{new RootCACustomTrustManager(remoteAddress, authStrictness, allowExpiredCertificate, certMap, caCertificate, crlDao)};
         sslContext.init(kmf.getKeyManagers(), tms, new SecureRandom());
         final SSLEngine sslEngine = sslContext.createSSLEngine();
-        sslEngine.setWantClientAuth(authStrictness);
+        sslEngine.setNeedClientAuth(authStrictness);
         return sslEngine;
     }
 
diff --git a/plugins/ca/root-ca/test/org/apache/cloudstack/ca/provider/RootCAProviderTest.java b/plugins/ca/root-ca/test/org/apache/cloudstack/ca/provider/RootCAProviderTest.java
index bdd3f08..44e2bcf 100644
--- a/plugins/ca/root-ca/test/org/apache/cloudstack/ca/provider/RootCAProviderTest.java
+++ b/plugins/ca/root-ca/test/org/apache/cloudstack/ca/provider/RootCAProviderTest.java
@@ -136,7 +136,7 @@ public class RootCAProviderTest {
         overrideDefaultConfigValue(RootCAProvider.rootCAAuthStrictness, "_defaultValue", "false");
         final SSLEngine e = provider.createSSLEngine(SSLUtils.getSSLContext(), "/1.2.3.4:5678", null);
         Assert.assertFalse(e.getUseClientMode());
-        Assert.assertFalse(e.getWantClientAuth());
+        Assert.assertFalse(e.getNeedClientAuth());
     }
 
     @Test
@@ -144,7 +144,7 @@ public class RootCAProviderTest {
         overrideDefaultConfigValue(RootCAProvider.rootCAAuthStrictness, "_defaultValue", "true");
         final SSLEngine e = provider.createSSLEngine(SSLUtils.getSSLContext(), "/1.2.3.4:5678", null);
         Assert.assertFalse(e.getUseClientMode());
-        Assert.assertTrue(e.getWantClientAuth());
+        Assert.assertTrue(e.getNeedClientAuth());
     }
 
     @Test
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/patchsystemvm.sh b/systemvm/patches/debian/config/opt/cloud/bin/patchsystemvm.sh
index 9222a8c..34450dc 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/patchsystemvm.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/patchsystemvm.sh
@@ -21,10 +21,21 @@ logfile="/var/log/patchsystemvm.log"
 # To use existing console proxy .zip-based package file
 patch_console_proxy() {
    local patchfile=$1
+   local backupfolder="/tmp/.conf.backup"
+   if [ -f /usr/local/cloud/systemvm/conf/cloud.jks ]; then
+      rm -fr $backupfolder
+      mkdir -p $backupfolder
+      cp -r /usr/local/cloud/systemvm/conf/* $backupfolder/
+   fi
    rm /usr/local/cloud/systemvm -rf
    mkdir -p /usr/local/cloud/systemvm
    echo "All" | unzip $patchfile -d /usr/local/cloud/systemvm >$logfile 2>&1
    find /usr/local/cloud/systemvm/ -name \*.sh | xargs chmod 555
+   if [ -f $backupfolder/cloud.jks ]; then
+      cp -r $backupfolder/* /usr/local/cloud/systemvm/conf/
+      echo "Restored keystore file and certs using backup" >> $logfile
+   fi
+   rm -fr $backupfolder
    return 0
 }
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@cloudstack.apache.org" <co...@cloudstack.apache.org>'].