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 =>
|
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))
|
||||||
{
|
{
|
||||||
adapterOptions.ServerCertificate = X509Certificate2.CreateFromPemFile(pemCertFile, pemKeyFile);
|
adapterOptions.ServerCertificate = X509Certificate2.CreateFromPemFile(pemCertFile, pemKeyFile);
|
||||||
}
|
}
|
||||||
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.
Reference in new issue
Block a user