diff --git a/src/Paket.Core/ConfigFile.fs b/src/Paket.Core/ConfigFile.fs index 763ca475ab..5f9d679695 100644 --- a/src/Paket.Core/ConfigFile.fs +++ b/src/Paket.Core/ConfigFile.fs @@ -55,7 +55,12 @@ let private getRandomSalt() = /// Encrypts a string with a user specific keys let Encrypt (password : string) = let salt = getRandomSalt() - let encryptedPassword = ProtectedData.Protect(Encoding.UTF8.GetBytes password, salt, DataProtectionScope.CurrentUser) + let encryptedPassword = + try + ProtectedData.Protect(Encoding.UTF8.GetBytes password, salt, DataProtectionScope.CurrentUser) + with | :? CryptographicException as e -> + verbosefn "could not protect password: %s\n for current user" e.Message + ProtectedData.Protect(Encoding.UTF8.GetBytes password, salt, DataProtectionScope.LocalMachine) salt |> Convert.ToBase64String , encryptedPassword |> Convert.ToBase64String