Fix
This commit is contained in:
1 parent
f5feec81f1
commit
d148901b9c
3 files changed
+7
-4
No files matched your search
@@ -14,15 +14,18 @@ builder.WebHost.ConfigureKestrel(options =>
|
||||
{
|
||||
options.ConfigureHttpsDefaults(adapterOptions =>
|
||||
{
|
||||
var pemCertFile = "app/data/certs/cert.pem";
|
||||
var pemKeyFile = "app/data/certs/key.pem";
|
||||
|
||||
//Get key file path from environment variable or configuration
|
||||
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))
|
||||
{
|
||||
adapterOptions.ServerCertificate = X509Certificate2.CreateFromPemFile(pemCertFile, pemKeyFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("PEM certificate or key file not found. Falling back to default development certificate.");
|
||||
|
||||
// No certificate found — fallback to default development certificate
|
||||
adapterOptions.ServerCertificate = null;
|
||||
}
|
||||
@@ -102,7 +105,7 @@ builder.Services.AddScoped<AppState>();
|
||||
|
||||
builder.Services.AddCascadingAuthenticationState();
|
||||
|
||||
if (bool.Parse(Environment.GetEnvironmentVariable("ENABLE_HSTS") ?? "false"))
|
||||
if (bool.Parse(Environment.GetEnvironmentVariable("ENABLE_HSTS") ?? "true"))
|
||||
{
|
||||
builder.Services.AddHsts(options =>
|
||||
{
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user