如何在 Linux 上为 IdentityServer4 配置密钥

Bop*_*Bop 5 linux security ssl-certificate asp.net-core identityserver4

我有一个带有 IdentityServer4 的 asp.net core 应用程序。在生产中它需要一个密钥。

在 Windows Server 上,我部署得很好 - 创建了一个自签名证书并添加LocalMacine/my为密钥位置。

我怎样才能在 Linux 上做同样的事情?

appsettings.jsonWindows 上的配置 - Linux 需要语法:

  "IdentityServer": {
    "Clients": {
      "MyDemoApp": {
        "Profile": "IdentityServerSPA"
      }
    },
    "Key": {
      "Type": "Store",
      "StoreName": "My",
      "StoreLocation": "LocalMachine",
      "Name": "CN=my-demo"
    }
  },
Run Code Online (Sandbox Code Playgroud)

And*_*ndy 1

您不能仅使用以下 appsettings 文件将您的证书作为 .pfx 文件引用:

{
  "Kestrel": {
    "Endpoints": {
      "Https": {
        "Url": "https://identityservice.local:6001",
        "Certificate": {
          "Path": "identityservice.local.pfx",
          "Password": "changeit"
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

或者,当我将 IdentityServer 部署为 Linux 容器时,我将证书存储在 Azure Key Vault 中。