Skip to content

Commit ac31fd1

Browse files
authored
Introduce GITHUB_ACTIONS_RUNNER_TLS_NO_VERIFY=1 to skip SSL cert verification for the runner. (#1616)
1 parent d8251bf commit ac31fd1

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/Runner.Common/HostContext.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ public HostContext(string hostType, string logFile = null)
193193
_trace.Info($"No proxy settings were found based on environmental variables (http_proxy/https_proxy/HTTP_PROXY/HTTPS_PROXY)");
194194
}
195195

196+
if (StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_TLS_NO_VERIFY")))
197+
{
198+
_trace.Warning($"Runner is running under insecure mode: HTTPS server certifcate validation has been turned off by GITHUB_ACTIONS_RUNNER_TLS_NO_VERIFY environment variable.");
199+
}
200+
196201
var credFile = GetConfigFile(WellKnownConfigFile.Credentials);
197202
if (File.Exists(credFile))
198203
{
@@ -350,7 +355,7 @@ public string GetConfigFile(WellKnownConfigFile configFile)
350355
GetDirectory(WellKnownDirectory.Root),
351356
".setup_info");
352357
break;
353-
358+
354359
case WellKnownConfigFile.Telemetry:
355360
path = Path.Combine(
356361
GetDirectory(WellKnownDirectory.Diag),

src/Runner.Common/HttpClientHandlerFactory.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Net.Http;
23
using GitHub.Runner.Sdk;
34

@@ -13,7 +14,14 @@ public class HttpClientHandlerFactory : RunnerService, IHttpClientHandlerFactory
1314
{
1415
public HttpClientHandler CreateClientHandler(RunnerWebProxy webProxy)
1516
{
16-
return new HttpClientHandler() { Proxy = webProxy };
17+
var client = new HttpClientHandler() { Proxy = webProxy };
18+
19+
if (StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_TLS_NO_VERIFY")))
20+
{
21+
client.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
22+
}
23+
24+
return client;
1725
}
1826
}
1927
}

src/Runner.Sdk/Util/VssUtil.cs

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public static void InitializeVssClientSettings(List<ProductInfoHeaderValue> addi
2727

2828
VssClientHttpRequestSettings.Default.UserAgent = headerValues;
2929
VssHttpMessageHandler.DefaultWebProxy = proxy;
30+
31+
if (StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_TLS_NO_VERIFY")))
32+
{
33+
VssClientHttpRequestSettings.Default.ServerCertificateValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
34+
}
3035
}
3136

3237
public static VssConnection CreateConnection(Uri serverUri, VssCredentials credentials, IEnumerable<DelegatingHandler> additionalDelegatingHandler = null, TimeSpan? timeout = null)

0 commit comments

Comments
 (0)