2023-06-02 21:47:59 +02:00
|
|
|
using System;
|
2020-04-23 17:02:13 -04:00
|
|
|
using System.Net.Http;
|
|
|
|
|
using GitHub.Runner.Sdk;
|
|
|
|
|
|
|
|
|
|
namespace GitHub.Runner.Common
|
|
|
|
|
{
|
|
|
|
|
[ServiceLocator(Default = typeof(HttpClientHandlerFactory))]
|
|
|
|
|
public interface IHttpClientHandlerFactory : IRunnerService
|
|
|
|
|
{
|
|
|
|
|
HttpClientHandler CreateClientHandler(RunnerWebProxy webProxy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class HttpClientHandlerFactory : RunnerService, IHttpClientHandlerFactory
|
|
|
|
|
{
|
|
|
|
|
public HttpClientHandler CreateClientHandler(RunnerWebProxy webProxy)
|
|
|
|
|
{
|
2022-01-19 10:31:17 -05:00
|
|
|
var client = new HttpClientHandler() { Proxy = webProxy };
|
|
|
|
|
|
|
|
|
|
if (StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_TLS_NO_VERIFY")))
|
|
|
|
|
{
|
|
|
|
|
client.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return client;
|
2020-04-23 17:02:13 -04:00
|
|
|
}
|
|
|
|
|
}
|
2023-06-02 21:47:59 +02:00
|
|
|
}
|