如何在 Linux 上为 IdentityServer4 配置密钥

How to configure Key for IdentityServer4 on Linux

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

在 Windows 服务器上,我成功部署了它 - 创建了一个自签名证书并添加了 LocalMacine/my 作为密钥位置。

如何在 Linux 上执行相同的操作?

appsettings.json 在 Windows 上配置 - 需要 Linux 的语法:

  "IdentityServer": {
    "Clients": {
      "MyDemoApp": {
        "Profile": "IdentityServerSPA"
      }
    },
    "Key": {
      "Type": "Store",
      "StoreName": "My",
      "StoreLocation": "LocalMachine",
      "Name": "CN=my-demo"
    }
  },

您能否不使用 appsettings 文件将您的证书称为 .pfx 文件,例如:

{
  "Kestrel": {
    "Endpoints": {
      "Https": {
        "Url": "https://identityservice.local:6001",
        "Certificate": {
          "Path": "identityservice.local.pfx",
          "Password": "changeit"
        }
      }
    }
  }
}

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