File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed
Umbraco.Infrastructure/HostedServices
Umbraco.Web.Common/DependencyInjection Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change
1
+ namespace Umbraco . Cms . Core
2
+ {
3
+ /// <summary>
4
+ /// Defines constants.
5
+ /// </summary>
6
+ public static partial class Constants
7
+ {
8
+ /// <summary>
9
+ /// Defines constants for named http clients.
10
+ /// </summary>
11
+ public static class HttpClients
12
+ {
13
+ /// <summary>
14
+ /// Name for http client which ignores certificate errors.
15
+ /// </summary>
16
+ public const string IgnoreCertificateErrors = "Umbraco:HttpClients:IgnoreCertificateErrors" ;
17
+ }
18
+ }
19
+ }
Original file line number Diff line number Diff line change 7
7
using System . Threading . Tasks ;
8
8
using Microsoft . Extensions . Logging ;
9
9
using Microsoft . Extensions . Options ;
10
+ using Umbraco . Cms . Core ;
10
11
using Umbraco . Cms . Core . Configuration . Models ;
11
12
using Umbraco . Cms . Core . Hosting ;
12
13
using Umbraco . Cms . Core . Logging ;
@@ -99,7 +100,7 @@ public override async Task PerformExecuteAsync(object state)
99
100
try
100
101
{
101
102
var request = new HttpRequestMessage ( HttpMethod . Get , keepAlivePingUrl ) ;
102
- HttpClient httpClient = _httpClientFactory . CreateClient ( ) ;
103
+ HttpClient httpClient = _httpClientFactory . CreateClient ( Constants . HttpClients . IgnoreCertificateErrors ) ;
103
104
_ = await httpClient . SendAsync ( request ) ;
104
105
}
105
106
catch ( Exception ex )
Original file line number Diff line number Diff line change 3
3
using System . Data . SqlClient ;
4
4
using System . IO ;
5
5
using System . Linq ;
6
+ using System . Net . Http ;
6
7
using System . Reflection ;
7
8
using Dazinator . Extensions . FileProviders . GlobPatternFilter ;
8
9
using Microsoft . AspNetCore . Builder ;
@@ -191,6 +192,11 @@ public static IUmbracoBuilder AddHostedServices(this IUmbracoBuilder builder)
191
192
private static IUmbracoBuilder AddHttpClients ( this IUmbracoBuilder builder )
192
193
{
193
194
builder . Services . AddHttpClient ( ) ;
195
+ builder . Services . AddHttpClient ( Constants . HttpClients . IgnoreCertificateErrors )
196
+ . ConfigurePrimaryHttpMessageHandler ( ( ) => new HttpClientHandler
197
+ {
198
+ ServerCertificateCustomValidationCallback = HttpClientHandler . DangerousAcceptAnyServerCertificateValidator
199
+ } ) ;
194
200
return builder ;
195
201
}
196
202
You can’t perform that action at this time.
0 commit comments