liveBook · Manning

Key file

As explained in ASP.NET Core in Action, 3e

A data protection key file is a small XML file containing cryptographic key material used by ASP.NET Core data protection for encryption and decryption.

A key file is a small XML file containing the random cryptographic key value that ASP.NET Core data protection uses to encrypt and decrypt data. The same key lets the application read protected authentication cookies and validate security tokens. section 29.2

Protect key files and choose storage that matches the hosting environment:

  • Treat the file as highly sensitive: anyone who obtains it may impersonate users and access protected data. section 29.2
  • Use the hosting environment’s protected location, such as an Azure Web App synced folder, encrypted registry storage, or the user-profile data-protection directory. section 29.2
  • In a web farm, store keys centrally—for example in a shared folder, Redis, or Azure Blob Storage—so every server can decrypt the same cookies. section 29.2
  • Avoid relying on in-memory keys when protected data must survive restarts; those keys are lost when the application stops. section 29.2

How ASP.NET Core in Action, 3e covers it

How deep it goes
Defines the XML file, explains its security significance and storage behavior, and stops short of configuration steps.
Examples
Uses Azure Web Apps, IIS, user-profile directories, in-memory storage, shared folders, Redis, and Azure Blob Storage as storage examples.
What you can do after
Operate/configure shared data-protection storage so distributed servers can read one another’s authentication cookies.
How it connects
Connects key files to data protection APIs, symmetric encryption, antiforgery tokens, authentication cookies, and CSRF attacks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.