title: Is there a way to configure the data protection provider for cookies in dotnet core 3.1?
body: <p>Locally cookies are created fine but after I deploy to my hosting environment no cookies are created because I have to persist data protection keys to the file system since user profile cannot be loaded in shared hosting environment. I changed the code locally to use the same mechanism to verify cookies are no longer created as this took me a while to track down. If there a way to configure the data protection provider for cookie creation? I have valid certs.</p>
  <pre><code>    public IServiceProvider ConfigureServices(IServiceCollection services) {
  
          //needed for winhost as we cannot get user profiles from IIS there
          if (_env.IsProduction()) {
              var certificate = new X509Certificate2($&quot;{_env.ContentRootPath}\\App_Data\\nameofcert.pfx&quot;, &quot;asdfasdf&quot;, X509KeyStorageFlags.Exportable);
               services.AddDataProtection()
                  .PersistKeysToFileSystem(new DirectoryInfo($&quot;{_env.ContentRootPath}\\App_Data&quot;))
              
                  .ProtectKeysWithCertificate(certificate);
          } else {
              var devCertificate = new X509Certificate2($&quot;{_env.ContentRootPath}\\App_Data\\cert.pfx&quot;, &quot;wasdfasdfas&quot;, X509KeyStorageFlags.Exportable);
              services.AddDataProtection()
                  .PersistKeysToFileSystem(new DirectoryInfo($&quot;{_env.ContentRootPath}\\App_Data&quot;))
                  
                  .ProtectKeysWithCertificate(devCertificate);
          }
  </code></pre>