Skip to content

Commit 5d64435

Browse files
committed
🧑‍💻 Change how IReport works #96
1 parent 86a77ee commit 5d64435

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Xecrets.Cli/Implementation/XecretsCliReport.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@
2727
using System.Text;
2828

2929
using AxCrypt.Abstractions;
30+
using AxCrypt.Core.Crypto.Asymmetric;
3031
using AxCrypt.Core.Runtime;
3132

33+
using Xecrets.Net.Core.Crypto.Asymmetric;
34+
3235
using static AxCrypt.Abstractions.TypeResolve;
3336

3437
namespace Xecrets.Cli.Implementation;
@@ -67,12 +70,23 @@ public void Exception(Exception ex)
6770
File.AppendAllText(fullName, sb.ToString());
6871
}
6972

73+
// NetPrivateKey is an internal type, but let's try to make future refactoring find the reference if something
74+
// changes in the future. The below check works only on Windows, but this one will work on all platforms.
75+
private static readonly string _rsaDecryptionStackMarker = $"at {typeof(NetAsymmetricFactory).FullName!.Replace(nameof(NetAsymmetricFactory), "NetPrivateKey")}.{nameof(IAsymmetricPrivateKey.Transform)}";
76+
7077
private static bool IgnoreException(Exception ex)
7178
{
79+
// Ignore simple failures to decrypt a private key
7280
if (ex is CryptographicException ce && ce.HResult == unchecked((int)0xc100000d))
7381
{
7482
return true;
7583
}
84+
85+
if ((ex.StackTrace ?? string.Empty).Contains(_rsaDecryptionStackMarker))
86+
{
87+
return true;
88+
}
89+
7690
return false;
7791
}
7892

0 commit comments

Comments
 (0)