Configures insecure HTTP client for proxy
All checks were successful
Build, Push and Run Container / build (push) Successful in 26s
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:
@@ -26,11 +26,16 @@ builder.Services.AddOpenApi();
|
|||||||
builder.Services.AddMediator();
|
builder.Services.AddMediator();
|
||||||
builder.Services.AddMemoryCache();
|
builder.Services.AddMemoryCache();
|
||||||
builder.Services.AddHybridCache();
|
builder.Services.AddHybridCache();
|
||||||
builder.Services.AddHttpClient();
|
|
||||||
builder.Services.AddRazorPages();
|
builder.Services.AddRazorPages();
|
||||||
builder.Services.AddHealthChecks()
|
builder.Services.AddHealthChecks()
|
||||||
.AddAsyncCheck("", cancellationToken => Task.FromResult(HealthCheckResult.Healthy()), ["ready"]); //TODO: Check tag
|
.AddAsyncCheck("", cancellationToken => Task.FromResult(HealthCheckResult.Healthy()), ["ready"]); //TODO: Check tag
|
||||||
builder.Services.AddHttpContextAccessor();
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
builder.Services.AddHttpClient().AddHttpClient("InsecureClient")
|
||||||
|
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
|
||||||
|
{
|
||||||
|
ServerCertificateCustomValidationCallback =
|
||||||
|
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
|
||||||
|
});
|
||||||
|
|
||||||
builder.Services
|
builder.Services
|
||||||
.AddAuthentication(o =>
|
.AddAuthentication(o =>
|
||||||
@@ -239,9 +244,9 @@ if (app.Environment.IsDevelopment())
|
|||||||
|
|
||||||
if (String.IsNullOrEmpty(access_token))
|
if (String.IsNullOrEmpty(access_token))
|
||||||
return Results.LocalRedirect("/Authorize");
|
return Results.LocalRedirect("/Authorize");
|
||||||
|
|
||||||
HttpClient client = httpClientFactory.CreateClient();
|
HttpClient client = httpClientFactory.CreateClient("InsecureClient");
|
||||||
client.BaseAddress = new Uri("tesla_command_proxy");
|
client.BaseAddress = new Uri("https://tesla_command_proxy");
|
||||||
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {access_token}");
|
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {access_token}");
|
||||||
client.DefaultRequestHeaders.Add("Content-Type", "application/json");
|
client.DefaultRequestHeaders.Add("Content-Type", "application/json");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user