Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use ProxyAddress with Credential when passed to powershell script #535

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: use ProxyAddress with Credential when passed to powershell script
In a proxy environment, such as in an enterprise, HTTP(S)_PROXY often takes the form of credentials, i.e., http://user:pass@host:port. 
When $ProxyAddress is passed in this format, WebProxy does not use the authentication information by default.
This PR aims to solve the above problem.
arika0093 authored Jul 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d10d64864fe6aa9f75edf1cc7537188d72f0082c
7 changes: 7 additions & 0 deletions externals/install-dotnet.ps1
Original file line number Diff line number Diff line change
@@ -416,6 +416,13 @@ function GetHTTPResponse([Uri] $Uri, [bool]$HeaderOnly, [bool]$DisableRedirect,
UseDefaultCredentials=$ProxyUseDefaultCredentials;
BypassList = $ProxyBypassList;
}
# If ProxyAddress is contained username and password, then set credentials
# e.g. http://(user):(pass)@...
if ($ProxyAddress -match '://(.*?):(.*?)@') {
$proxyUsername = $matches[1]
$proxyPassword = $matches[2]
$HttpClientHandler.Proxy.Credentials = New-Object System.Net.NetworkCredential($proxyUsername, $proxyPassword)
}
}
if ($DisableRedirect)
{