private HttpClient CreateHttpClient(ProgressMessageHandler progressHandler) { var httpClientHandler = new HttpClientHandler(); progressHandler.InnerHandler = httpClientHandler; if (_authenticationMechanism.IgnoreSsl) { httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true; } else if (_authenticationMechanism.ValidationCallback != null) { httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => _authenticationMechanism.ValidationCallback(message, cert, chain, errors); } var client = new HttpClient(progressHandler); // do not time out on streaming requests, let the cancellation token handle timeouts client.Timeout = Timeout.InfiniteTimeSpan; return(client); }