在 asp.net 核心 DataProtection api 中找不到 ProtectKeysWithCertificate 方法

ProtectKeysWithCertificate Method not found in asp.net core DataProtection api

我在添加 ProtectKeysWithCertificate 这一行时遇到编译时错误

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

in the documentation 所示,ProtectKeysWithCertificate() 在 .NET Core 1.0/1.1 (netcoreapp1.x) 上不可用。

如果要使用它,可以针对完整的 .NET Framework(例如 net461)。