diff --git a/Src/Fido2.Models/Converters/Base64UrlConverter.cs b/Src/Fido2.Models/Converters/Base64UrlConverter.cs index 473313a0..3210c6db 100644 --- a/Src/Fido2.Models/Converters/Base64UrlConverter.cs +++ b/Src/Fido2.Models/Converters/Base64UrlConverter.cs @@ -12,6 +12,8 @@ namespace Fido2NetLib; /// public sealed class Base64UrlConverter : JsonConverter { + public static bool EnableRelaxedDecoding { get; set; } + public override byte[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { byte[]? rentedBuffer = null; @@ -39,7 +41,14 @@ public override byte[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonS { if (Base64.IsValid(source)) { - throw new JsonException("Expected data to be in Base64Url format, but received Base64 encoding instead"); + if (EnableRelaxedDecoding) + { + return Base64Url.DecodeFromUtf8(source); + } + else + { + throw new JsonException("Expected data to be in Base64Url format, but received Base64 encoding instead."); + } } else {