Search code examples
c#asp.netasp.net-coreopeniddict

ProtectKeysWithCertificate Method not found in asp.net core DataProtection api


I got compile time error on add of ProtectKeysWithCertificate this line

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    services.AddDataProtection()
        .SetApplicationName("Testervice")
        .ProtectKeysWithCertificate(newCert);
        //compile time error on ProtectKeysWithCertificate line
       //method not found
}

Solution

  • As indicated in the documentation, ProtectKeysWithCertificate() is not available on .NET Core 1.0/1.1 (netcoreapp1.x).

    If you want to use it, you can target the full .NET Framework (e.g net461).