From b0e211dde5284e9453ad4681ac596a6b0ce02b5b Mon Sep 17 00:00:00 2001 From: Aydin Mir Mohammadi Date: Mon, 4 Nov 2024 23:07:15 +0100 Subject: [PATCH] Ignor ssl errors on energy charts api --- ...arbonAwareComputing.ForecastUpdater.Function.csproj | 3 ++- .../ForecastUpdateFunction.cs | 2 ++ .../Startup.cs | 10 +++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/CarbonAwareComputing.ForecastUpdater.Function/CarbonAwareComputing.ForecastUpdater.Function.csproj b/src/CarbonAwareComputing.ForecastUpdater.Function/CarbonAwareComputing.ForecastUpdater.Function.csproj index f5fa4fe..c92a10e 100644 --- a/src/CarbonAwareComputing.ForecastUpdater.Function/CarbonAwareComputing.ForecastUpdater.Function.csproj +++ b/src/CarbonAwareComputing.ForecastUpdater.Function/CarbonAwareComputing.ForecastUpdater.Function.csproj @@ -12,9 +12,10 @@ + - + diff --git a/src/CarbonAwareComputing.ForecastUpdater.Function/ForecastUpdateFunction.cs b/src/CarbonAwareComputing.ForecastUpdater.Function/ForecastUpdateFunction.cs index 12930ba..b816245 100644 --- a/src/CarbonAwareComputing.ForecastUpdater.Function/ForecastUpdateFunction.cs +++ b/src/CarbonAwareComputing.ForecastUpdater.Function/ForecastUpdateFunction.cs @@ -30,7 +30,9 @@ public class ForecastUpdateFunction public ForecastUpdateFunction(IHttpClientFactory httpClientFactory, IOptions applicationSettings) { m_ApplicationSettings = applicationSettings; + m_Http = httpClientFactory.CreateClient(); + } diff --git a/src/CarbonAwareComputing.ForecastUpdater.Function/Startup.cs b/src/CarbonAwareComputing.ForecastUpdater.Function/Startup.cs index f5603bc..d56e37d 100644 --- a/src/CarbonAwareComputing.ForecastUpdater.Function/Startup.cs +++ b/src/CarbonAwareComputing.ForecastUpdater.Function/Startup.cs @@ -3,6 +3,8 @@ using Microsoft.Extensions.DependencyInjection; using System.Reflection; using System; +using System.Net.Http; +using Microsoft.Extensions.Options; [assembly: FunctionsStartup(typeof(CarbonAwareComputing.ForecastUpdater.Function.Startup))] namespace CarbonAwareComputing.ForecastUpdater.Function; @@ -13,7 +15,13 @@ public override void Configure(IFunctionsHostBuilder builder) // Note: Only register dependencies, do not depend or request those in Configure(). // Dependencies are only usable during function execution, not before (like here). - builder.Services.AddHttpClient(); + builder.Services.AddHttpClient(Options.DefaultName).ConfigurePrimaryHttpMessageHandler(() => + { + return new HttpClientHandler + { + ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, certChain, policyErrors) => true + }; + }); builder.Services.AddOptions() .Configure((settings, configuration) => {