/// <summary>
        /// Get prepared HttpClient with correct system proxy settings
        /// </summary>
        /// <returns></returns>
        public HttpClient GetHttpClient(bool checkSsl = true)
        {
            var httpClientHandler = new LoggingHttpClientHandler(_log)
            {
                Proxy        = GetWebProxy(),
                SslProtocols = SslProtocols
            };

            if (!checkSsl)
            {
                httpClientHandler.ServerCertificateCustomValidationCallback = (a, b, c, d) => true;
            }
            if (UseSystemProxy && !useEnvVariableProxy)
            {
                httpClientHandler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;
            }
            return(new HttpClient(httpClientHandler));
        }
Exemple #2
0
        public HttpMessageHandler GetHttpMessageHandler(bool checkSsl = true)
        {
            var httpClientHandler = new LoggingHttpClientHandler(_log)
            {
                Proxy        = GetWebProxy(),
                SslProtocols = SslProtocols,
            };

            if (!checkSsl)
            {
                httpClientHandler.ServerCertificateValidationCallback = (a, b, c, d) => true;
            }
            httpClientHandler.WindowsProxyUsePolicy = ProxyType;
            if (ProxyType == WindowsProxyUsePolicy.UseWinInetProxy)
            {
                httpClientHandler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;
            }
            return(httpClientHandler);
        }
Exemple #3
0
        /// <summary>
        /// Get prepared HttpClient with correct system proxy settings
        /// </summary>
        /// <returns></returns>
        public HttpClient GetHttpClient(bool checkSsl = true)
        {
            var httpClientHandler = new LoggingHttpClientHandler(_log)
            {
                Proxy        = GetWebProxy(),
                SslProtocols = SslProtocols,
            };

            if (!checkSsl)
            {
                httpClientHandler.ServerCertificateCustomValidationCallback = (a, b, c, d) => true;
            }
            if (UseSystemProxy)
            {
                httpClientHandler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;
            }
            var httpClient = new HttpClient(httpClientHandler);

            httpClient.DefaultRequestHeaders.Add("User-Agent", $"win-acme/{VersionService.SoftwareVersion} (+https://github.com/win-acme/win-acme)");
            return(httpClient);
        }