System.Security.Cryptography.CryptographicException: Key Not Valid For Use In Specified State

How to fix "System.Security.Cryptography.CryptographicException: Key not valid for use in specified state"?

This error can occur when a user is trying to use the Get Password activity and deploying the process from dev to production environment (or moving the process from one machine to another machine).

Note: The activity only work for the same user on the same machine.

Root Cause: Get Password activity encrypts a password by associating it with the current user. Only workflows running under the current user context can decrypt the password. Thus, executing the project from another machine or user context generates this exception.


Resolution:

  1. Use Get Credential activity that fetches the credential from the UiPath Orchestrator.
  2. Get Secure Credential activity can be used to fetch the credential from the Windows Credential manager. This can be used as an alternate in an environment where there is no Orchestrator setup. ​​​