Partager via


CryptographicException while adding TFS connection to ReleaseManagement Update-4 client

One of our customer reported below error :-

Issue:- While adding a TFS connection, user were getting CryptographicException

Message: Bad Data.
: \r\n\r\n   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
   at System.Security.Cryptography.RSACryptoServiceProvider.DecryptKey(SafeKeyHandle pKeyContext, Byte[] pbEncryptedKey, Int32 cbEncryptedKey, Boolean fOAEP, ObjectHandleOnStack ohRetDecryptedKey)
   at System.Security.Cryptography.RSACryptoServiceProvider.Decrypt(Byte[] rgb, Boolean fOAEP)
   at Microsoft.TeamFoundation.Release.Data.Helpers.CryptoHelper.GetDecryptedValue(String str, String containerName)
   at Microsoft.TeamFoundation.Release.Data.Helpers.CryptoHelper.DecryptString(String str, String cryptoContainerName, String key, Encryption encryption)
   at Microsoft.TeamFoundation.Release.Data.Proxy.LocalProxy.EncryptionServiceLocalProxy.<.ctor>b__1(String x)
   at Microsoft.TeamFoundation.Release.Data.Proxy.LocalProxy.EncryptionServiceLocalProxy.Decrypt(String encryptionLocation)
   at Microsoft.TeamFoundation.Release.Tfs.TfsHelperBase.SecureCredential.ToNetworkCredential()
   at Microsoft.TeamFoundation.Release.Tfs.TfsHelperBase.GetCacheCredentialOfTFSServiceAccount(String tfsUrl)
   at Microsoft.TeamFoundation.Release.Tfs.TfsHelperBase.GetTeamProjectCollectionForServiceUser(String tfsUrl)
   at Microsoft.TeamFoundation.Release.Tfs.TfsHelperBase.GetTfsDetails(String tfsUrl, String userName, String encryptedPassword)
   at Microsoft.TeamFoundation.Release.ServiceProcessor.Processor.TfsServiceProcessor.GetTfsDetails(String tfsUrl, String userName, String encryptedPassword, Int32 tfsVersionId)

 

How it got fixed :-

From above call stack, It seems like the crypto key present on the customer machine were corrupt and hence Decrypt() were failing. Perform following steps to fix it (Note: You might have to re-enter password again at all places in your ReleaseTemplate and all other place) :-

1. Navigate to %ALLUSERSPROFILE%\Application Data\Microsoft\Crypto\RSA\MachineKeys on the RM server machine and look for the key that looks like this - 918fda7df45a07822a6a453544ec6f66_<SomeGuid>. Take a back-up of the key and delete it.

2. Close ReleaseManagement Client and Server window

3. Re-configure ReleaseManagement server (this will create the give with 918fda7df45a07822a6a453544ec6f66_<SomeGuid> again.

4. Try configuring your TFS again. it should work

5. Done!!!!