From f0f0de0076813bc32eed9d56748310af2e5b52cd Mon Sep 17 00:00:00 2001 From: CitrixChris <86611314+CitrixChris@users.noreply.github.com> Date: Thu, 10 Mar 2022 14:16:13 +0000 Subject: [PATCH] CA-364330 wraps cyptoexception in try catch to show appropriate message (#2968) Signed-off-by: Christophe25 --- .../Updates/DownloadAndUpdateClientAction.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/XenModel/Actions/Updates/DownloadAndUpdateClientAction.cs b/XenModel/Actions/Updates/DownloadAndUpdateClientAction.cs index 6a070dddb..8b4ca4ac2 100644 --- a/XenModel/Actions/Updates/DownloadAndUpdateClientAction.cs +++ b/XenModel/Actions/Updates/DownloadAndUpdateClientAction.cs @@ -222,22 +222,23 @@ namespace XenAdmin.Actions throw new Exception(Messages.UPDATE_CLIENT_INVALID_CHECKSUM ); } - bool valid; - // Check digital signature of .msi - using (var basicSigner = X509Certificate.CreateFromSignedFile(outputPathAndFileName)) + bool valid = false; + try { - using (var cert = new X509Certificate2(basicSigner)) + // Check digital signature of .msi + using (var basicSigner = X509Certificate.CreateFromSignedFile(outputPathAndFileName)) { - try + using (var cert = new X509Certificate2(basicSigner)) { valid = cert.Verify(); } - catch (Exception e) - { - throw new Exception(Messages.UPDATE_CLIENT_FAILED_CERTIFICATE_CHECK, e); - } } } + catch (Exception e) + { + throw new Exception(Messages.UPDATE_CLIENT_FAILED_CERTIFICATE_CHECK, e); + } + if (!valid) throw new Exception(Messages.UPDATE_CLIENT_INVALID_DIGITAL_CERTIFICATE);