Skip to content

Commit 22d9998

Browse files
committed
Some formatting and rewording
1 parent 6ce179c commit 22d9998

1 file changed

Lines changed: 19 additions & 21 deletions

File tree

astro/src/content/docs/general/data-protection.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,27 @@ builder.Services.AddDataProtection()
4747
```
4848

4949
:::danger[Ensure data protection keys are persisted]
50-
Always make sure data protection is configured to persist data protection keys to storage, using `.PersistKeys...()`
50+
Always make sure data protection is configured to persist data protection keys to storage, using `.PersistKeysTo...()`
5151
for your storage mechanism. If you lose your data protection keys, all data protected with those keys is no longer be readable.
5252

53-
Additionally ensure the storage mechanism itself is durable. For example, if you are using the default file system
53+
Additionally, ensure the storage mechanism itself is durable. For example, if you are using the default file system
5454
based key store, make sure that the configured path is not stored on ephemeral storage. If you are using Redis to store
5555
data protection keys using `PersistKeysToStackExchangeRedis()`, ensure that your Redis service is configured to persist
56-
data to a database backup or append-only file. Otherwise you will lose all data
57-
protection keys when your Redis instance reboots.
56+
data to a database backup or append-only file. Otherwise, you will lose all data protection keys when your Redis instance reboots.
5857

59-
For a more advanced setup, you can create a [key escrow sink](https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/extensibility/key-management?view=aspnetcore-10.0#xmlkeymanager), allowing you to store new data protection keys into a secure storage (e.g., Azure Key Vault) before the new keys are encrypted. This enables you to restore existing data protection keys in case they become corrupted or lost.
58+
For a more advanced setup, you can create a [key escrow sink](https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/extensibility/key-management?view=aspnetcore-10.0#xmlkeymanager), allowing you to store new data protection keys into
59+
a secure storage (e.g., Azure Key Vault) before the new keys are encrypted.
60+
This enables you to restore existing data protection keys in case they become corrupted or lost.
6061
:::
6162

62-
6363
## Common Problems
6464

6565
Common data protection problems occur when data is protected with a key that is not available when the data is later
6666
read. A common symptom is `CryptographicException`s in the application logs. For example, when IdentityServer's automatic key
6767
management fails to read its signing keys due to a data protection failure, it will log an error message
68-
such as "Error unprotecting key with kid {Signing Key ID}.", and log the underlying
69-
`System.Security.Cryptography.CryptographicException`, with a message like "The key {Data Protection Key ID} was not
70-
found in the key ring."
68+
such as `"Error unprotecting key with kid {Signing Key ID}."`, and log the underlying
69+
`System.Security.Cryptography.CryptographicException`, with a message like `"The key {Data Protection Key ID} was not
70+
found in the key ring."`
7171

7272
Failures to read automatic signing keys are often the first place where a data protection problem manifests, but any of
7373
many places where ASP.NET uses data protection might also throw `CryptographicException`s.
@@ -82,16 +82,14 @@ There are several ways that data protection problems can occur:
8282
directory from source control and make sure keys are not included in your builds. Note that if you are using our
8383
Entity Framework based implementation of the operational data stores, then the keys will instead be stored in the
8484
database.
85-
3. Data protection creates keys isolated by application name. If you don't specify a name, the content root path of the
86-
application will be used. But, beginning in .NET 6.0 Microsoft changed how they handle the path, which can cause data
87-
protection keys to break. Their docs on the problem
88-
are [here](https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview#setapplicationname),
89-
including a work-around where you de-normalize the path. Then, in .NET 7.0, this change was reverted. The solution is
90-
always to specify an explicit application name, and if you have old keys that were generated without an explicit
91-
application name, you need to set your application name to match the default behavior that produced the keys you want
92-
to be able to read.
93-
4. If you host on IIS, special configuration is needed for data protection. In most default
94-
deployments, IIS lacks the permissions required to persist data protection keys, and falls back to using an ephemeral
95-
key generated every time the site starts up. Microsoft's docs on this issue
96-
are [here](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/advanced?view=aspnetcore-7.0#data-protection).
85+
3. Data protection derives keys isolated per application name from the generated key material. If you don't specify a name,
86+
the content root path of the application will be used. In .NET 6.0, Microsoft introduced a breaking change: they changed
87+
how ASP.NET Core sets the content root path, which can cause Data Protection issues. This change was reverted in .NET 7.0,
88+
and Microsoft has [documented a workaround in case your application has to restore the correct application name](https://learn.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview#set-the-application-name-setapplicationname).
89+
A better solution is to always specify an explicit application name, but know that changing the application name will
90+
cause all existing data protected with the previous application name to become unreadable.
91+
4. When hosting your web application on Microsoft IIS, [special configuration may be required for data protection](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/advanced#data-protection).
92+
In most default deployments, IIS falls back to using an ephemeral storage for data protection keys, which means that
93+
new keys are generated every time the application pool restarts. We recommend storing data protection keys in a shared location,
94+
such as a protected file share or database, and configuring IIS to use that location for data protection.
9795

0 commit comments

Comments
 (0)