Skip to content

Commit 3f46dbc

Browse files
committed
corrections to GetCryptoValues (#90, #91) for eating errors and genkey keysize
1 parent afec6c5 commit 3f46dbc

7 files changed

Lines changed: 16 additions & 14 deletions

File tree

Synapse.Common/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@
3838
// by using the '*' as shown below:
3939
// [assembly: AssemblyVersion("1.0.*")]
4040
[assembly: AssemblyVersion( "1.0.0.0" )]
41-
[assembly: AssemblyFileVersion( "1.0.18181.0" )]
41+
[assembly: AssemblyFileVersion( "1.0.18184.0" )]

Synapse.Core/Classes/CryptoProvider.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,11 @@ internal string SafeHandleCrypto(string s)
8585
//try to decrypt
8686
// - if success, then the value is already encrypted with these RSA keys, return orig string (s)
8787
// - if failure, needs to be encrypted
88-
string decrypted = null;
89-
if( !TryDecryptOrValue( s, out decrypted ) )
90-
TryEncryptOrValue( s, out response );
88+
if( !TryDecryptOrValue( s, out string decrypted ) )
89+
response = Encrypt( s );
9190
}
9291
else
93-
TryDecryptOrValue( s, out response );
92+
response = Decrypt( s );
9493

9594
return response;
9695
}

Synapse.Core/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@
3636
// by using the '*' as shown below:
3737
// [assembly: AssemblyVersion("1.0.*")]
3838
[assembly: AssemblyVersion( "1.0.0.0" )]
39-
[assembly: AssemblyFileVersion( "1.0.18181.0" )]
39+
[assembly: AssemblyFileVersion( "1.0.18184.0" )]

Synapse.Core/Utilities/CryptoHelpers.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public static void GenerateRsaKeys(string keyContainerName = null, string pubPri
5454
if( string.IsNullOrWhiteSpace( keyContainerName ) && string.IsNullOrWhiteSpace( pubPrivFilePath ) && string.IsNullOrWhiteSpace( pubOnlyFilePath ) )
5555
throw new ArgumentException( "Invalid argument" );
5656

57+
if( string.IsNullOrWhiteSpace( keyContainerName ) )
58+
keyContainerName = null;
59+
5760
CspParameters cspParams = new CspParameters
5861
{
5962
KeyContainerName = keyContainerName

Synapse.Core/Utilities/XmlHelpers.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,11 @@ public static T GetCryptoValues<T>(T c, ref XmlDocument source, bool isEncryptMo
512512
src.Value = c.Crypto.SafeHandleCrypto( src.Value );
513513
}
514514
else
515-
errors.Add( element );
515+
errors.Add( $"Element: [{element}] failed with error: [SelectSingleNode returned null]." );
516516
}
517-
catch
517+
catch( Exception ex )
518518
{
519-
errors.Add( element );
519+
errors.Add( $"Element: [{element}] failed with error: [{ex.Message.Trim()}]." );
520520
}
521521
}
522522

Synapse.Core/Utilities/YamlHelpers.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public static void SerializeFile(string path, object data, bool serializeAsJson
5454
String origFile = $"{path}.tmp";
5555
File.Move( path, origFile );
5656
using( StreamReader raw = new StreamReader( origFile ) )
57-
using( StreamWriter formatted = new StreamWriter( path ) )
58-
JsonHelpers.FormatJson( raw, formatted );
57+
using( StreamWriter formatted = new StreamWriter( path ) )
58+
JsonHelpers.FormatJson( raw, formatted );
5959

6060
File.Delete( origFile );
6161
}
@@ -492,9 +492,9 @@ public static T GetCryptoValues<T>(T c, bool isEncryptMode = true) where T : cla
492492
Dictionary<object, object> patch = ConvertPathElementToDict( element );
493493
HandleElementCrypto( source, patch, c.Crypto );
494494
}
495-
catch
495+
catch( Exception ex )
496496
{
497-
errors.Add( element );
497+
errors.Add( $"Element: [{element}] failed with error: [{ex.Message.Trim()}]." );
498498
}
499499
}
500500

Synapse.cli/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion( "1.0.0.0" )]
36-
[assembly: AssemblyFileVersion( "1.0.18181.0" )]
36+
[assembly: AssemblyFileVersion( "1.0.18184.0" )]

0 commit comments

Comments
 (0)