OneGet/TestBuild

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

Opened this issue ยท 11 comments

anpur commented

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.

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 commented

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

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.

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

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.

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.

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

@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.

Is there a fix for this on Win7 now?

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.

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