diff --git a/src/OpenIddict.Abstractions/OpenIddictResources.resx b/src/OpenIddict.Abstractions/OpenIddictResources.resx
index 2222dda2..ed48e9c7 100644
--- a/src/OpenIddict.Abstractions/OpenIddictResources.resx
+++ b/src/OpenIddict.Abstractions/OpenIddictResources.resx
@@ -1119,6 +1119,9 @@ To register the OpenIddict core services, reference the 'OpenIddict.Core' packag
The specified principal doesn't contain a valid claims-based identity.
+
+ The payload of this authentication ticket was serialized using an unsupported formatter version.
+
The security token is missing.
diff --git a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs
index 2f02cb8c..850bb211 100644
--- a/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs
+++ b/src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs
@@ -16,6 +16,7 @@ using System.Text.Json;
using OpenIddict.Abstractions;
using static OpenIddict.Abstractions.OpenIddictConstants;
using Properties = OpenIddict.Server.DataProtection.OpenIddictServerDataProtectionConstants.Properties;
+using SR = OpenIddict.Abstractions.OpenIddictResources;
namespace OpenIddict.Server.DataProtection
{
@@ -66,7 +67,7 @@ namespace OpenIddict.Server.DataProtection
var version = reader.ReadInt32();
if (version != 5)
{
- return (null, ImmutableDictionary.Create());
+ throw new InvalidOperationException(SR.GetResourceString(SR.ID0287));
}
// Read the authentication scheme associated to the ticket.
@@ -150,9 +151,9 @@ namespace OpenIddict.Server.DataProtection
{
// Read the version of the format used to serialize the properties.
var version = reader.ReadInt32();
- if (version != 5)
+ if (version != 1)
{
- return ImmutableDictionary.Create();
+ throw new InvalidOperationException(SR.GetResourceString(SR.ID0287));
}
var count = reader.ReadInt32();
@@ -363,7 +364,7 @@ namespace OpenIddict.Server.DataProtection
static void WriteProperties(BinaryWriter writer, IReadOnlyDictionary properties)
{
// Write the version of the format used to serialize the properties.
- writer.Write(/* version: */ 5);
+ writer.Write(/* version: */ 1);
writer.Write(properties.Count);
foreach (var property in properties)
diff --git a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionFormatter.cs b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionFormatter.cs
index a27d1c96..9d73173d 100644
--- a/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionFormatter.cs
+++ b/src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionFormatter.cs
@@ -13,6 +13,7 @@ using System.Text.Json;
using OpenIddict.Abstractions;
using static OpenIddict.Abstractions.OpenIddictConstants;
using Properties = OpenIddict.Validation.DataProtection.OpenIddictValidationDataProtectionConstants.Properties;
+using SR = OpenIddict.Abstractions.OpenIddictResources;
namespace OpenIddict.Validation.DataProtection
{
@@ -63,7 +64,7 @@ namespace OpenIddict.Validation.DataProtection
var version = reader.ReadInt32();
if (version != 5)
{
- return (null, ImmutableDictionary.Create());
+ throw new InvalidOperationException(SR.GetResourceString(SR.ID0287));
}
// Read the authentication scheme associated to the ticket.
@@ -147,9 +148,9 @@ namespace OpenIddict.Validation.DataProtection
{
// Read the version of the format used to serialize the properties.
var version = reader.ReadInt32();
- if (version != 5)
+ if (version != 1)
{
- return ImmutableDictionary.Create();
+ throw new InvalidOperationException(SR.GetResourceString(SR.ID0287));
}
var count = reader.ReadInt32();