首页 > 解决方案 > 如何在 Linux 上为 IdentityServer4 配置密钥

问题描述

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

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

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

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

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

标签: linuxasp.net-coresecurityssl-certificateidentityserver4

解决方案


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

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

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


推荐阅读