Nuget with Artifactory. Key not valid for use in specified state

Gourav picture Gourav · Apr 1, 2015 · Viewed 8.9k times · Source

I am using Artifactory as NuGet repository to store all the nuget packages. When we use this Artifactory link as source, the package Manager in Visual Studio prompts for credentials and worked very fine. As soon as we moved to build machine (with out VS) and try to build application it is throwing error :

.nuget\NuGet.targets(100,9): error : Key not valid for use in specified state.

I added source with -user -password and put config at local user location. I tried with ClearText password and encrypted password both are throwing same error.

Am I missing anything here? Please advice.

Answer

Shrike picture Shrike · May 29, 2015

I believe the error isn't related to Artifactory. The issue NuGet reports is related with encrypting/decrypting user credentials in nuget.config files.

I encountered the error when I tried to set apiKey for a repo:

NuGet setapikey user:pwd -Config .\NuGet.test.Config -Source .\packages

NuGet reported "Key not valid for use in specified state". I had NuGet.config file located near NuGet.test.Config. That nuget.config contained packageSourceCredentials section with credentials of other user (than one which was passed to setapikey). After I remove that credentials from nuget.config the error gone.