Configures insecure HTTP client for proxy
All checks were successful
Build, Push and Run Container / build (push) Successful in 26s

Adds named HTTP client configuration with insecure settings to
communicate with the tesla_command_proxy, which uses a self-signed
certificate.

Changes the base address to use HTTPS.
This commit is contained in:
2025-08-17 12:17:01 +02:00
parent 3663595f78
commit 0ac37d198c

View File

@@ -26,11 +26,16 @@ builder.Services.AddOpenApi();
builder.Services.AddMediator();
builder.Services.AddMemoryCache();
builder.Services.AddHybridCache();
builder.Services.AddHttpClient();
builder.Services.AddRazorPages();
builder.Services.AddHealthChecks()
.AddAsyncCheck("", cancellationToken => Task.FromResult(HealthCheckResult.Healthy()), ["ready"]); //TODO: Check tag
builder.Services.AddHttpContextAccessor();
builder.Services.AddHttpClient().AddHttpClient("InsecureClient")
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
{
ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
});
builder.Services
.AddAuthentication(o =>
@@ -240,8 +245,8 @@ if (app.Environment.IsDevelopment())
if (String.IsNullOrEmpty(access_token))
return Results.LocalRedirect("/Authorize");
HttpClient client = httpClientFactory.CreateClient();
client.BaseAddress = new Uri("tesla_command_proxy");
HttpClient client = httpClientFactory.CreateClient("InsecureClient");
client.BaseAddress = new Uri("https://tesla_command_proxy");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {access_token}");
client.DefaultRequestHeaders.Add("Content-Type", "application/json");