This commit is contained in:
rossmill76 committed 2026-03-07 16:19:24 +00:00
1 parent f5feec81f1
commit d148901b9c
3 files changed
+6 -3

No files matched your search

+6 -3
View File
@@ -14,8 +14,9 @@ builder.WebHost.ConfigureKestrel(options =>
{ {
options.ConfigureHttpsDefaults(adapterOptions => options.ConfigureHttpsDefaults(adapterOptions =>
{ {
var pemCertFile = "app/data/certs/cert.pem"; //Get key file path from environment variable or configuration
var pemKeyFile = "app/data/certs/key.pem"; var pemCertFile = Environment.GetEnvironmentVariable("PEM_CERT_FILE") ?? builder.Configuration["PemCertFile"] ?? "/app/data/certs/cert.pem";
var pemKeyFile = Environment.GetEnvironmentVariable("PEM_KEY_FILE") ?? builder.Configuration["PemKeyFile"] ?? "/app/data/certs/key.pem";
if (File.Exists(pemCertFile) && File.Exists(pemKeyFile)) if (File.Exists(pemCertFile) && File.Exists(pemKeyFile))
{ {
@@ -23,6 +24,8 @@ builder.WebHost.ConfigureKestrel(options =>
} }
else else
{ {
Console.WriteLine("PEM certificate or key file not found. Falling back to default development certificate.");
// No certificate found — fallback to default development certificate // No certificate found — fallback to default development certificate
adapterOptions.ServerCertificate = null; adapterOptions.ServerCertificate = null;
} }
@@ -102,7 +105,7 @@ builder.Services.AddScoped<AppState>();
builder.Services.AddCascadingAuthenticationState(); builder.Services.AddCascadingAuthenticationState();
if (bool.Parse(Environment.GetEnvironmentVariable("ENABLE_HSTS") ?? "false")) if (bool.Parse(Environment.GetEnvironmentVariable("ENABLE_HSTS") ?? "true"))
{ {
builder.Services.AddHsts(options => builder.Services.AddHsts(options =>
{ {
Binary file not shown.
Binary file not shown.