Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Proxy support #1

Closed
ferventcoder opened this issue Sep 2, 2011 · 15 comments
Closed

Proxy support #1

ferventcoder opened this issue Sep 2, 2011 · 15 comments
Assignees

Comments

@ferventcoder
Copy link
Contributor

original: ferventcoder/nugetpackages#29

http://www.streamline-it-solutions.co.uk/blog/post/Getting-through-a-proxy-server-with-PowerShell.aspx

@ferventcoder
Copy link
Contributor Author

@ghost ghost assigned ferventcoder Sep 2, 2011
@ferventcoder
Copy link
Contributor Author

fixed in 63cf4e0

@ldsenow
Copy link

ldsenow commented Nov 1, 2011

I am having an error while installing one of the packages

A positional parameter cannot be found that accepts argument 'proxy.company.private:8080'

@ferventcoder
Copy link
Contributor Author

Which package are you seeing this with? Or is it any package?

@ldsenow
Copy link

ldsenow commented Nov 1, 2011

the chocolatey version is 0.9.8.11 and I was installing nodejs. But not only installing nodejs

@ferventcoder
Copy link
Contributor Author

do you guys have a proxy in place?

Someone else reported issues with the proxy code that we took from a patch.

If you go to C:\NuGet\chocolateyInstall\helpers\chocolateyInstaller.psm1

and comment out lines 499-507:

  if (!$webclient.Proxy.IsBypassed($url))
  {
    $cred = get-credential
    $proxyaddress = $webclient.Proxy.GetProxy($url).Authority
    Write-host "Using this proxyserver: " $proxyaddress
    $proxy = New-Object System.Net.WebProxy($proxyaddress)
    $proxy.credentials = $cred.GetNetworkCredential();
    $req.proxy = $proxy
  }

to be

#  if (!$webclient.Proxy.IsBypassed($url))
#  {
#    $cred = get-credential
#    $proxyaddress = $webclient.Proxy.GetProxy($url).Authority
#    Write-host "Using this proxyserver: " $proxyaddress
#    $proxy = New-Object System.Net.WebProxy($proxyaddress)
#    $proxy.credentials = $cred.GetNetworkCredential();
#    $req.proxy = $proxy
#  }

Then tell me what you see.

@dansward
Copy link

Attempting to install not (cinst nodejs)

With those lines commented out I get...

Downloading nodejs (http://nodejs.org/dist/v0.6.0/node.exe) to C:\NuGet\lib\nodejs.0.6.0\tools\node.exe

[ERROR] nodejs did not finish successfully. Boo to the chocolatey gods!

[ERROR] Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (407) Proxy Authentication Required."

Without them commented out I get...

Downloading nodejs (http://nodejs.org/dist/v0.6.0/node.exe) to C:\NuGet\lib\nodejs.0.6.0\tools\node.exe

[ERROR] nodejs did not finish successfully. Boo to the chocolatey gods!

[ERROR] A positional parameter cannot be found that accepts argument '10.0.100.2:8080'.

I do have a proxy in place and the argument it is complaining about is it. Without those lines commented it requests my credentials.

@ferventcoder
Copy link
Contributor Author

We need better proxy support. :(

@ferventcoder ferventcoder reopened this Dec 6, 2011
@vermeeca
Copy link

FWIW, this seemed to work for me:

if (!$webclient.Proxy.IsBypassed($url))
  {
    #$cred = get-credential
    $proxyaddress = $webclient.Proxy.GetProxy($url).Authority
    Write-host "Using this proxyserver: $proxyaddress"
    #$proxy = New-Object System.Net.WebProxy($proxyaddress)
    #$proxy.credentials = $cred.GetNetworkCredential();
    #$req.proxy = $proxy
    $req.proxy.credentials = [System.Net.CredentialCache]::DefaultCredentials;
  }

@ferventcoder
Copy link
Contributor Author

Fixing this again for the first time, for the last time? ;)

@ferventcoder
Copy link
Contributor Author

Hopefully this is fixed with the latest bits coming in 0.9.8.17. If not we will add a config value to specify your proxy type.

@yoshimov
Copy link

Almost all packages are not working inside of our auth proxy with Chocolatey 0.9.8.20
The Chocolatey commands (clist, cver, etc.) are still working correctly, and it is working to retry the request with new credential when the proxy returns 407 status code.
Here is my modification.
yoshimov@60705c3

@grenade
Copy link

grenade commented Jan 30, 2014

Working with Chocolatey v0.9.8.23, cinst was not working from behind an ISA proxy using NTLM until C:\Chocolatey\chocolateyinstall\helpers\functions\Get-WebFile.ps1 was modified like so:

  #if (!$webclient.Proxy.IsBypassed($url))
  #{
  #  $creds = [net.CredentialCache]::DefaultCredentials
  #  if ($creds -eq $null) {
  #    Write-Debug "Default credentials were null. Attempting backup method"
  #    $cred = get-credential
  #    $creds = $cred.GetNetworkCredential();
  #  }
  #  $proxyaddress = $webclient.Proxy.GetProxy($url).Authority
  #  Write-host "Using this proxyserver: $proxyaddress"
  #  $proxy = New-Object System.Net.WebProxy($proxyaddress)
  #  $proxy.credentials = $creds
  # $req.proxy = $proxy
  #}
  if (!$webclient.Proxy.IsBypassed($url))
  {
    $proxyaddress = $webclient.Proxy.GetProxy($url).Authority
    Write-host "Using this proxyserver: $proxyaddress"
    $req.proxy.credentials = [net.CredentialCache]::DefaultCredentials
  }

@ferventcoder
Copy link
Contributor Author

I'm thinking we'll want to do some configuration file stuff for proxies since there seems to be different ways of handling the way in

@ferventcoder
Copy link
Contributor Author

@grenade would you file a new issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants