Skip to content

Commit 8eaee62

Browse files
authored
add breaking change for shouldgeneratenewkey (#40284)
1 parent 3cda7ea commit 8eaee62

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

docs/core/compatibility/9.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff
1515
>
1616
> This article is a work in progress. It's not a complete list of breaking changes in .NET 9. To query breaking changes that are still pending publication, see [Issues of .NET](https://issuesof.net/?q=%20is:open%20-label:Documented%20is:issue%20(label:%22Breaking%20Change%22%20or%20label:breaking-change)%20(repo:dotnet/docs%20or%20repo:aspnet/Announcements)%20group:repo%20(label:%22:checkered_flag:%20Release:%20.NET%209%22%20or%20label:9.0.0)%20sort:created-desc).
1717
18+
## ASP.NET Core
19+
20+
| Title | Type of change | Introduced version |
21+
|------------------------------------------------------------------------------------------|---------------------|--------------------|
22+
| [DefaultKeyResolution.ShouldGenerateNewKey has altered meaning](aspnet-core/9.0/key-resolution.md) | Behavioral change | Preview 3 |
23+
1824
## Core .NET libraries
1925

2026
| Title | Type of change | Introduced version |
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: "Breaking change: DefaultKeyResolution.ShouldGenerateNewKey has altered meaning"
3+
description: Learn about the breaking change in ASP.NET Core 9.0 where DefaultKeyResolution.ShouldGenerateNewKey has a slightly altered meaning.
4+
ms.date: 04/01/2024
5+
---
6+
# DefaultKeyResolution.ShouldGenerateNewKey has altered meaning
7+
8+
`DefaultKeyResolution.ShouldGenerateNewKey` no longer reflects whether the default key is close to its expiration time.
9+
10+
## Version introduced
11+
12+
ASP.NET Core 9.0 Preview 3
13+
14+
## Previous behavior
15+
16+
It was an undocumented, but consistent, feature of the API that `ShouldGenerateNewKey` was `true` if the default key was within two days (an oversimplification) of its expiration time. The amount of lead time was based on the polling interval of `ICacheableKeyRingProvider`, which was not something `IDefaultKeyResolver.ResolveDefaultKeyPolicy` should have depended upon (since, for example, alternative implementations would probably not be aware of these details).
17+
18+
## New behavior
19+
20+
Starting in .NET 9, if `ShouldGenerateNewKey` is `true`, it indicates that either there's no default key or that for some other policy reason (in a specialized implementation of `IDefaultKeyResolver`), a new key should be generated. The `ICacheableKeyRingProvider` makes its own decision about whether the expiration time is close enough to warrant generating a new key.
21+
22+
## Type of breaking change
23+
24+
This change is a [behavioral change](../../categories.md#behavioral-change).
25+
26+
## Reason for change
27+
28+
This change was made for two reasons:
29+
30+
- To change the logic around key generation near expiration time.
31+
- To make it simpler to implement a custom `IDefaultKeyResolver`.
32+
33+
## Recommended action
34+
35+
If you have an `IDefaultKeyResolver` implementation that tries to replicate the expiry logic, you can remove that logic (however, leaving it is fine as well).
36+
37+
If you were consuming `IDefaultKeyResolver` directly to determine whether expiration was pending, you can check the default key's `ExpirationDate` property directly.
38+
39+
## Affected APIs
40+
41+
- `Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.DefaultKeyResolution.ShouldGenerateNewKey`

docs/core/compatibility/toc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ items:
88
items:
99
- name: Overview
1010
href: 9.0.md
11+
- name: ASP.NET Core
12+
items:
13+
- name: DefaultKeyResolution.ShouldGenerateNewKey has altered meaning
14+
href: aspnet-core/9.0/key-resolution.md
1115
- name: Core .NET libraries
1216
items:
1317
- name: Creating type of array of System.Void not allowed
@@ -928,6 +932,10 @@ items:
928932
items:
929933
- name: ASP.NET Core
930934
items:
935+
- name: .NET 9
936+
items:
937+
- name: DefaultKeyResolution.ShouldGenerateNewKey has altered meaning
938+
href: aspnet-core/9.0/key-resolution.md
931939
- name: .NET 8
932940
items:
933941
- name: ConcurrencyLimiterMiddleware is obsolete

0 commit comments

Comments
 (0)