File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
src/Xecrets.Cli/Implementation Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 2727using System . Text ;
2828
2929using AxCrypt . Abstractions ;
30+ using AxCrypt . Core . Crypto . Asymmetric ;
3031using AxCrypt . Core . Runtime ;
3132
33+ using Xecrets . Net . Core . Crypto . Asymmetric ;
34+
3235using static AxCrypt . Abstractions . TypeResolve ;
3336
3437namespace 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
You can’t perform that action at this time.
0 commit comments