简体   繁体   English

将上传到 Azure 门户的 TLS 证书加载到 Linux 应用服务容器中

[英]Loading a TLS certificate uploaded to the Azure portal into a Linux app service container

For some time we've had an ASP.NET Core web app running on an Azure App Service.一段时间以来,我们在 Azure 应用服务上运行了一个 ASP.NET Core Web 应用。 As part of upgrading to netcoreapp2.2 we've decided to Dockerize it and run it on a Linux container, still in an app service.作为升级到 netcoreapp2.2 的一部分,我们决定对它进行 Dockerize 并在 Linux 容器上运行它,仍然在应用程序服务中。

One thing this app does is load in a TLS certificate for token signing.此应用程序所做的一件事是加载 TLS 证书以进行令牌签名。 Previously this certificate was uploaded to the app service and the application would find it by thumbprint in a new X509Store(StoreName.My, StoreLocation.CurrentUser) .以前,此证书已上传到应用程序服务,应用程序将通过指纹在new X509Store(StoreName.My, StoreLocation.CurrentUser)找到它。 This could be enabled by adding a configuration setting WEBSITE_LOAD_CERTIFICATES with value set to the certificate's thumbprint.这可以通过添加配置设置WEBSITE_LOAD_CERTIFICATES并将值设置为证书的指纹来启用。

Having tried the same approach with a Linux container we're finding the certificate doesn't exist in the certificate store.对 Linux 容器尝试了相同的方法后,我们发现证书存储中不存在该证书。

I found this issue on Github from earlier this year which suggests it's just not possible on Linux.我从今年早些时候在 Github 上发现了这个问题,这表明它在 Linux 上是不可能的。 Is this still the case?现在还是这样吗? If so, does anyone know a work-around which doesn't involve storing the certificate itself in the image?如果是这样,有没有人知道不涉及将证书本身存储在图像中的解决方法?

The feature now works on Linux.该功能现在适用于 Linux。

Load certificate in Linux apps 在 Linux 应用程序中加载证书

The WEBSITE_LOAD_CERTIFICATES app settings makes the specified certificates accessible to your Linux hosted apps (including custom container apps) as files. WEBSITE_LOAD_CERTIFICATES 应用程序设置使您的 Linux 托管应用程序(包括自定义容器应用程序)可以作为文件访问指定的证书。 The files are found under the following directories:这些文件位于以下目录下:

  • Private certificates - /var/ssl/private ( .p12 files)私有证书 - /var/ssl/private(.p12 文件)
  • Public certificates - /var/ssl/certs ( .der files)公共证书 - /var/ssl/certs(.der 文件)

The certificate file names are the certificate thumbprints.证书文件名是证书指纹。 The following C# code shows how to load a public certificate in a Linux app.以下 C# 代码显示了如何在 Linux 应用程序中加载公共证书。

 using System; using System.Security.Cryptography.X509Certificates; var bytes = System.IO.File.ReadAllBytes("/var/ssl/certs/<thumbprint>.der"); var cert = new X509Certificate2(bytes);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CallerFilePathAttribute不返回Azure的Linux容器应用程序服务上具有有效目录分隔符的文件路径 - CallerFilePathAttribute not returning file path with valid directory separators on azure's linux container app service 对 Azure Linux 应用服务中运行的容器进行健康检查 - HealthCheck for the containers running in the Azure Linux App service 关于Linux计划的Azure应用服务计划编码问题 - Azure App Service on Linux plan encoding issue Azure 应用服务 Linux 安装依赖项 - Azure App service Linux install dependencies 使用 Azure DevOps 在 Azure 应用服务中永久安装 Linux 依赖项 - Install Linux dependencies in Azure App Service permanently using Azure DevOps 将 gRPC 服务部署到 Azure Linux 应用服务 - 端口未打开 - Deploy gRPC service to Azure Linux App Service - port not open 如何通过 ssh 进入 Azure 上的“Web App On Linux”docker 容器? - How can I ssh into “Web App On Linux” docker container on Azure? 无法在 Azure 应用服务 Linux 中部署 NodeJS(Fastify 应用) - Unable to deploy NodeJS (Fastify app) in Azure App Service Linux 将 .net core 3.1 Web 应用部署到 Azure Linux 应用服务 - Deploying .net core 3.1 web app to Azure Linux App Service SQL 连接来自 Azure Linux 应用服务 Z2567A5EC9705EB7AC2C98409DZE0 - SQL Connection from Azure Linux App Service web app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM