I have an Asp.net core 3.1 web app in docker and in Azure Service Fabric.
The asp.net core web app has https enabled and gets its Certificate from AzureKeyVault. When deployed it seems the https is not responding but http works.
The console host looks so
public static void ConfigureKestrelServer(this IWebHostBuilder host)
{
try
{
host.ConfigureKestrel(options =>
{
options.ConfigureHttpsDefaults(listenOptions =>
{
listenOptions.ServerCertificate = GetCertificateFromStore();
});
});
}
catch (System.Exception e)
{
throw;
}
}
public static X509Certificate2 GetCertificateFromStore()
{
return AzureKeyVaultExtensions.GetCertificateSecretAsync().GetAwaiter().GetResult();
}
The code above is able to download the certificate when deployed. The docker file looks like this
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
ARG source
WORKDIR /app
ADD ${source} .
ENV APP_UTILS=C:\\app
VOLUME ${APP_UTILS}
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["dotnet", "MyWebApp.dll"]