Skip to content

Commit 9f3ecfb

Browse files
TingluoHuangsirredbeard
authored andcommitted
Allow NO_SSL_VERIFY in RawHttpMessageHandler. (actions#3883)
1 parent 59d3823 commit 9f3ecfb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Runner.Sdk/Util/VssUtil.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static void InitializeVssClientSettings(List<ProductInfoHeaderValue> addi
3838
if (StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_TLS_NO_VERIFY")))
3939
{
4040
VssClientHttpRequestSettings.Default.ServerCertificateValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
41+
RawClientHttpRequestSettings.Default.ServerCertificateValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
4142
}
4243

4344
var rawHeaderValues = new List<ProductInfoHeaderValue>();

src/Sdk/Common/Common/RawHttpMessageHandler.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ protected override async Task<HttpResponseMessage> SendAsync(
106106
{
107107
VssTraceActivity traceActivity = VssTraceActivity.Current;
108108

109+
if (!m_appliedServerCertificateValidationCallbackToTransportHandler &&
110+
request.RequestUri.Scheme == "https")
111+
{
112+
HttpClientHandler httpClientHandler = m_transportHandler as HttpClientHandler;
113+
if (httpClientHandler != null &&
114+
this.Settings.ServerCertificateValidationCallback != null)
115+
{
116+
httpClientHandler.ServerCertificateCustomValidationCallback = this.Settings.ServerCertificateValidationCallback;
117+
}
118+
m_appliedServerCertificateValidationCallbackToTransportHandler = true;
119+
}
120+
109121
lock (m_thisLock)
110122
{
111123
// Ensure that we attempt to use the most appropriate authentication mechanism by default.
@@ -291,6 +303,7 @@ private static void ApplySettings(
291303
}
292304
}
293305

306+
private bool m_appliedServerCertificateValidationCallbackToTransportHandler;
294307
private readonly HttpMessageHandler m_transportHandler;
295308
private HttpMessageInvoker m_messageInvoker;
296309
private CredentialWrapper m_credentialWrapper;

0 commit comments

Comments
 (0)