From 06edfd9b0e79ea7e13780bd9fe0e92a35a790263 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sat, 1 Jun 2013 20:54:01 +0100 Subject: [PATCH] windows: Don't crash and show a warning when FIPS is enabled. Closes #1298 --- SparkleLib/SparkleFetcherSSH.cs | 15 ++++++++++++++- SparkleShare/SparkleControllerBase.cs | 10 +++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/SparkleLib/SparkleFetcherSSH.cs b/SparkleLib/SparkleFetcherSSH.cs index d55a9de8..68fcba22 100644 --- a/SparkleLib/SparkleFetcherSSH.cs +++ b/SparkleLib/SparkleFetcherSSH.cs @@ -33,8 +33,21 @@ namespace SparkleLib { bool warn = true; if (RequiredFingerprint != null) { - string host_fingerprint = DeriveFingerprint (host_key); + string host_fingerprint; + + try { + host_fingerprint = DeriveFingerprint (host_key); + } catch (InvalidOperationException e) { + // "Unapproved cryptographic algorithms" won't work when FIPS is enabled on Windows. + // Software like Cisco AnyConnect can demand this feature is on, so we show an error + SparkleLogger.LogInfo ("Auth", "Unable to derive fingerprint: ", e); + this.errors.Add ("error: Can't check fingerprint due to FIPS being enabled"); + + return false; + } + + if (host_fingerprint == null || !RequiredFingerprint.Equals (host_fingerprint)) { SparkleLogger.LogInfo ("Auth", "Fingerprint doesn't match"); this.errors.Add ("error: Host fingerprint doesn't match"); diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index 309a6712..e77c12b4 100644 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -695,7 +695,15 @@ namespace SparkleShare { string avatars_path = new string [] { Path.GetDirectoryName (this.config.FullPath), "avatars", size + "x" + size }.Combine (); - string avatar_file_path = Path.Combine (avatars_path, email.MD5 () + ".png"); + string avatar_file_path; + + try { + avatar_file_path = Path.Combine (avatars_path, email.MD5 () + ".png"); + + } catch (InvalidOperationException e) { + SparkleLogger.LogInfo ("Controller", "Error fetching avatar for " + email, e); + return null; + } if (File.Exists (avatar_file_path)) { if (new FileInfo (avatar_file_path).CreationTime < DateTime.Now.AddDays (-1))