Fix cert issue
This commit is contained in:
1 parent
65a71c5b5f
commit
f5feec81f1
3 files changed
+15
-16
No files matched your search
+15
-16
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using BudgetApp.Components;
|
using BudgetApp.Components;
|
||||||
@@ -9,25 +10,22 @@ using BudgetApp.Data.Interfaces;
|
|||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
builder.Host.ConfigureWebHostDefaults(webBuilder =>
|
builder.WebHost.ConfigureKestrel(options =>
|
||||||
{
|
{
|
||||||
webBuilder.ConfigureKestrel(options =>
|
options.ConfigureHttpsDefaults(adapterOptions =>
|
||||||
{
|
{
|
||||||
options.ConfigureHttpsDefaults(adapterOptions =>
|
var pemCertFile = "app/data/certs/cert.pem";
|
||||||
{
|
var pemKeyFile = "app/data/certs/key.pem";
|
||||||
var pemCertFile = "app/data/certs/cert.pem";
|
|
||||||
var pemKeyFile = "app/data/certs/key.pem";
|
|
||||||
|
|
||||||
if (File.Exists(pemCertFile) && File.Exists(pemKeyFile))
|
if (File.Exists(pemCertFile) && File.Exists(pemKeyFile))
|
||||||
{
|
{
|
||||||
adapterOptions.ServerCertificate = System.Security.Cryptography.X509Certificates.X509Certificate2.CreateFromPemFile(pemCertFile, pemKeyFile);
|
adapterOptions.ServerCertificate = X509Certificate2.CreateFromPemFile(pemCertFile, pemKeyFile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// No certificate found — fallback to default development certificate
|
// No certificate found — fallback to default development certificate
|
||||||
adapterOptions.ServerCertificate = null;
|
adapterOptions.ServerCertificate = null;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -121,6 +119,7 @@ builder.Services.AddRazorComponents()
|
|||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|
||||||
// Auto-migrate database
|
// Auto-migrate database
|
||||||
using (var scope = app.Services.CreateScope())
|
using (var scope = app.Services.CreateScope())
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user