logger added

This commit is contained in:
andrei-mihnea-cerbu
2024-05-02 14:21:34 +03:00
665 changed files with 9158 additions and 4633 deletions
+5 -31
View File
@@ -9,37 +9,11 @@ using Microsoft.AspNetCore.Server.Kestrel.Https;
var builder = WebApplication.CreateBuilder(args);
builder.Logging.ClearProviders();
builder.Logging.AddConsole();
builder.Logging.AddDebug();
// Specify the paths to your certificate and key files
var certPath = Path.Combine(Directory.GetCurrentDirectory(), "cert.pem");
var keyPath = Path.Combine(Directory.GetCurrentDirectory(), "key.pem");
// Load the certificate and key
var certificate = new X509Certificate2(certPath);
var privateKeyText = File.ReadAllText(keyPath);
var rsaPrivateKey = RSA.Create();
rsaPrivateKey.ImportFromPem(privateKeyText.ToCharArray());
// Combine the certificate and private key into one X509Certificate2 object
var certificateWithKey = certificate.CopyWithPrivateKey(rsaPrivateKey);
builder.WebHost.ConfigureKestrel(serverOptions =>
// Configure Kestrel with certificate paths from appsettings.json
builder.WebHost.ConfigureKestrel((context, serverOptions) =>
{
serverOptions.ListenAnyIP(5000); // Set HTTP port
serverOptions.ListenAnyIP(5001, listenOptions => // Set HTTPS port
{
// Apply the certificate with the private key to HTTPS
listenOptions.UseHttps(new HttpsConnectionAdapterOptions
{
ServerCertificate = certificateWithKey,
ClientCertificateMode = ClientCertificateMode.NoCertificate
});
});
});;
serverOptions.Configure(context.Configuration.GetSection("Kestrel"), reloadOnChange: true);
});
builder.Services.AddCors(options =>
{
@@ -113,4 +87,4 @@ static void EnsureDatabaseCreated(HealthcareManagerDatabase dbContext)
{
// Checking for pending migrations is more efficient than applying migrations unconditionally
if (dbContext.Database.GetPendingMigrations().Any()) dbContext.Database.Migrate();
}
}