mirror of https://github.com/apache/cloudstack.git
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 <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
74ec9cefca
commit
0dfdbe064c
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue