Skip to content

CryptographicException: Key not valid for use in specified state. #2627

Open
@lucalandi

Description

@lucalandi

Description

I'm getting this exception from one of our Windows Server 2016 slaves.
This is reproducible with paket versions: 3.27.0, 5.85.8

stderr: Paket failed with
-> CryptographicException: Key not valid for use in specified state.
   
   StackTrace:
        at System.Security.Cryptography.ProtectedData.Unprotect(Byte[] encryptedData, Byte[] optionalEntropy, DataProtectionScope scope)
        at Paket.ConfigFile.Decrypt(String salt, String encrypted)
        at Paket.ConfigFile.getAuthFromNode(XmlNode node)
        at [email protected](XmlNode _arg1)
        at Chessie.ErrorHandling.Trial.fSuccess@66-11[p,r,q](FSharpFunc`2 f, p x, FSharpList`1 msgs)
        at <StartupCode$Paket-Core>[email protected](Unit unitVar0)
        at Paket.Utils.RunInLockedAccessMode[a](String rootFolder, FSharpFunc`2 action)
        at [email protected](ParseResults`1 results)
        at Paket.Program.processWithValidation[T](Boolean silent, FSharpFunc`2 validateF, FSharpFunc`2 commandF, ParseResults`1 result)
        at Paket.Program.main$cont@721(ParseResults`1 results, Boolean silent, Boolean fromBootstrapper, Unit unitVar)
        at Paket.Program.main()

Repro steps

cmd: paket config add-credentials https://myget.org/F/feed/api/v2 --username user --password password --verbose

Expected behavior

It should not fail.

Actual behavior

Exceptions thrown.

Known workarounds

This issue is caused by a local paket.config file which contains an encrypted password that is probably expired if you are getting that exception. The only solution I found is to remove the file in:
C:\Users\user\AppData\Roaming\Paket\paket.config
and rerun the command:
cmd: paket config add-credentials https://myget.org/F/feed/api/v2 --username user --password password --verbose

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions