summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-04-16 16:40:56 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2012-04-16 16:40:56 -0700
commiteb111f5e257416f359fc06df432f06f53845f0e6 (patch)
treef185cfadee8af2950ba73a46a78dddd8932617df /src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
parent4fefd4dac5970d0a294dfe3278c70f5fdd8da08f (diff)
downloadDotNetOpenAuth-eb111f5e257416f359fc06df432f06f53845f0e6.zip
DotNetOpenAuth-eb111f5e257416f359fc06df432f06f53845f0e6.tar.gz
DotNetOpenAuth-eb111f5e257416f359fc06df432f06f53845f0e6.tar.bz2
Added logging for why crypto keys are created.
Diffstat (limited to 'src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs')
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
index 4e75145..87fc8a7 100644
--- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
@@ -806,6 +806,12 @@ namespace DotNetOpenAuth.Messaging {
var cryptoKeyPair = cryptoKeyStore.GetKeys(bucket).FirstOrDefault(pair => pair.Value.Key.Length == keySize / 8);
if (cryptoKeyPair.Value == null || cryptoKeyPair.Value.ExpiresUtc < DateTime.UtcNow + minimumRemainingLife) {
// No key exists with enough remaining life for the required purpose. Create a new key.
+ if (cryptoKeyPair.Value == null) {
+ Logger.Messaging.InfoFormat("{0}.GetKeys returned no keys for bucket \"{1}\" with the required key length of {2} bits. A new key will be created", typeof(ICryptoKeyStore), bucket, keySize);
+ } else {
+ Logger.Messaging.InfoFormat("The first key returned by {0}.GetKeys for bucket \"{1}\" with the required key length of {2} bits was too near expiry to use. A new key will be created", typeof(ICryptoKeyStore), bucket, keySize);
+ }
+
ErrorUtilities.VerifyHost(minimumRemainingLife <= SymmetricSecretKeyLifespan, "Unable to create a new symmetric key with the required lifespan of {0} because it is beyond the limit of {1}.", minimumRemainingLife, SymmetricSecretKeyLifespan);
byte[] secret = GetCryptoRandomData(keySize / 8);
DateTime expires = DateTime.UtcNow + SymmetricSecretKeyLifespan;