Azure Key Vault:AADSTS700024:.NET Core,Linux 容器。客户端断言不在其有效时间范围内

Azure Key Vault: AADSTS700024: .NET Core, Linux Container. Client assertion is not within its valid time range

我在从 ASP .NET Core 应用 运行 连接到 docker 容器中的 Azure Key Vault 时遇到了问题。

该应用正在使用 clientID/Certificate 对保管库进行身份验证。 我已经注册了一个应用程序并授予它使用保险库的权限。

当我 运行 docker 中的应用程序时,我不断收到此错误:

Unhandled exception. Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException: AADSTS700024: Client assertion is not within its valid time range. Current time: 2020-03-11T00:06:34.4692395Z, expiry time of assertion 2020-03-10T11:40:33.0000000Z.

NuGet: Microsoft.Extensions.Configuration.AzureKeyVault v3.1.2
Nuget: Microsoft.Azure.KeyVault v.3.0.5
NuGet: Microsoft.Azure.Services.AppAuthentication v1.0.3
NuGet: Microsoft.IdentityModel.Clients.ActiveDirectory v3.14.2

以下是保险库在 ConfigureAppConfiguration

中的配置方式
X509Certificate2Collection collection = new X509Certificate2Collection();
collection.Import(path, pwd, X509KeyStorageFlags.PersistKeySet);

var cert = collection[0];

config.AddAzureKeyVault(
                         vault,
                         clientId: builtConfig["ApplicationId"],
                         certificate: cert);

好像docker容器里的时间不同步。一些 aps.net 图像有这个问题:3168

您可以通过以下方式查看时区和日期:

# Replace the image with yours
docker run -it mcr.microsoft.com/dotnet/framework/runtime:4.7.2-windowsservercore-1803 powershell

# Then check timezone and date in powershell 

Get-Timezone
Get-Date