Skip to content

Commit

Permalink
CLOUDSTACK-9993: With auth strictness stop SSL handshake for rogue cl…
Browse files Browse the repository at this point in the history
…ients (apache#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 <rohit.yadav@shapeblue.com>
  • Loading branch information
rohityadavcloud authored Oct 4, 2017
1 parent 74ec9ce commit 0dfdbe0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public SSLEngine createSSLEngine(final SSLContext sslContext, final String remot
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ public void testCreateSSLEngineWithoutAuthStrictness() throws Exception {
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
public void testCreateSSLEngineWithAuthStrictness() throws Exception {
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
Expand Down
11 changes: 11 additions & 0 deletions systemvm/patches/debian/config/opt/cloud/bin/patchsystemvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 0dfdbe0

Please sign in to comment.