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

PSModule doesn't support Nuget packages with authentification (HTTPS) #2

Open
anpur opened this issue Jan 7, 2016 · 11 comments
Open

Comments

@anpur
Copy link

anpur commented Jan 7, 2016

Prerequisites:

  1. Setup some HTTPS Nuget server which requires authentication
  2. Update your PackageManager to 1.0.0.1 version with Win November Update (it used to work in 1.0.0.0)

Scenario:

  1. Check that Nuget.exe can install packages from your Nuget server
  2. Try to register it as PSRepository:
    Register-PSRepository -Name MyNuget -SourceLocation https://my-nuget/api/v2

You will got error like this:
Register-PSRepository : The specified Uri 'https://my-nuget/api/v2' for parameter 'SourceLocation' is an invalid Web Uri. Please ensure that it meets the Web Uri requirements.

Root cause:
Function Ping-Module from PSModule.psm1 not passing credentials to request.

Fix is not simple
To fix Ping-Module you need simple one-liner: you need to add following line to $WebRequestcmd script inside Ping-Module function:

$request.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

But after that fix I'm getting following warning:

WARNING: Unable to resolve package source 'https://my-nuget/api/v2'.

So source is registered but remains unusable.

Please feel free to contact me for any additional details or reproduction.

@michaeltlombardi
Copy link

I've come across the same error after deploying an instance of the PSPrivateGallery to azure.

The default PowerShellGallery is registered over https, which is interesting.

@anpur
Copy link
Author

anpur commented Jul 6, 2016

Hey Michael, there is temporary workaround available for this issue : http://stackoverflow.com/a/35296483

@michaeltlombardi
Copy link

Unfortunately, that work around requires me to distribute it to everyone in our shop who might use the PowerShell repo. Definitely need a longer term solution. I'll check to see if that workaround gets it done for me, but I'll still have to make it available over http for now either way.

@adbertram
Copy link

Any movement on this? I'm hitting this now.

@thomasrayner
Copy link

Would also like to see a fix for this. Just hit it, too.

The temporary work-around posted by @anpur is working for me right now, but it's awfully janky to need to do that.

@Benny1007
Copy link

Hey, was there a fix to this? I am running into it in current Powershell, but I notice this issue is logged under testbuild. Bit confused with the whole oneget, powershellget, powershellgallery and packagemanagement modules and terminology, seems like a bit of a stuff up, but not being able to register an https package source seems like a fundamental issue.

@Halkcyon
Copy link

Halkcyon commented Dec 1, 2017

I've heard there was a fix for this in the latest Win10 build @Ben-Shirley

@briantist
Copy link

@TheIncorrigible1 yeah it works in Windows 10. Frustratingly, the version numbers of both the PowerShellGet and PackageManagement modules are the same down to the last digit (1.0.0.1) on systems where it works and where it doesn't. It's unbelievably ridiculous; I can't even test for this on a given platform without trying it.

@danielrolfe
Copy link

danielrolfe commented Apr 14, 2018

Is there a fix for this on Win7 now?

@larssb
Copy link

larssb commented May 3, 2018

Just chipping in here. As I hope this can be usefull to someone.

  • This could also happen when the HTTPS endpoint us protected by a non-matching certificate. The endpoint name does not match the name used in the URI.

@jzabroski
Copy link

Open for almost 3 years and still no fix. Where's the hustle?

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

No branches or pull requests

10 participants