diff --git a/Src/Fido2.AspNet/DistributedCacheMetadataService.cs b/Src/Fido2.AspNet/DistributedCacheMetadataService.cs index fe68620d..a4a78a3c 100644 --- a/Src/Fido2.AspNet/DistributedCacheMetadataService.cs +++ b/Src/Fido2.AspNet/DistributedCacheMetadataService.cs @@ -1,5 +1,7 @@ using System.Text.Json; +using Fido2NetLib.Serialization; + using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Internal; @@ -103,7 +105,7 @@ protected virtual async Task StoreDistributedCachedBlob(IMetadataRepository repo { await _distributedCache.SetStringAsync( GetBlobCacheKey(repository), - JsonSerializer.Serialize(payload), + JsonSerializer.Serialize(payload, FidoModelSerializerContext.Default.MetadataBLOBPayload), new DistributedCacheEntryOptions() { AbsoluteExpiration = GetDistributedCacheAbsoluteExpiryTime(GetNextUpdateTimeFromPayload(payload)) @@ -120,7 +122,7 @@ protected virtual async Task<MetadataBLOBPayload> GetDistributedCachedBlob(IMeta { try { - var cachedBlob = JsonSerializer.Deserialize<MetadataBLOBPayload>(distributedCacheEntry); + var cachedBlob = JsonSerializer.Deserialize(distributedCacheEntry, FidoModelSerializerContext.Default.MetadataBLOBPayload); var nextUpdateTime = GetNextUpdateTimeFromPayload(cachedBlob); //If the cache until time is in the past then update and return new data, otherwise return the cached value