How to fix 'Crypto' exception when running previously working TFS Mac Build Agent?

1

The TFS build agent on my Mac host was working until I recently upgraded Visual Studio and installed PowerShell 6.2.3 using homebrew. The version of Visual Studio Enterprise is now 8.4 (Build 2535).

The build agent was running just before I restarted the Mac host, as per Visual Studio upgrade requirements. The first time I attempted to start the agent again with . run.sh on the command-line, it no longer worked. We attempted to install a new agent with the latest build on another Mac host and had similar problems. Is there a breaking change?

I have attempted repairing openssl, as suggested in these links: https://github.com/microsoft/azure-pipelines-agent/issues/232

https://social.msdn.microsoft.com/Forums/vstudio/en-US/f2f61f67-156e-4163-8cd3-ad882b7bc26d/config-build-agent-faile-on-macsystemtypeinitializationexception-the-type-initializer-for?forum=tfsbuild

I have removed powershell with brew cask uninstall powershell

With all of these steps taken, the agent will still not start.

I found logs in the build agent's _diag directory. It appears that the exception occurs when loading RSA commands:

[2020-01-09 01:01:15Z INFO CredentialManager] Creating type OAuth [2020-01-09 01:01:15Z INFO CredentialManager] Creating credential type: OAuth [2020-01-09 01:01:15Z INFO RSAFileKeyManager] Loading RSA key parameters from file /Users/Shared/tfsbuildagent/.credentials_rsaparams [2020-01-09 01:01:15Z ERR Terminal] WRITE ERROR: An error occurred: The type initializer for 'Crypto' threw an exception. [2020-01-09 01:01:15Z ERR AgentProcess] System.TypeInitializationException: The type initializer for 'Crypto' threw an exception. ---> System.TypeInitializationException: The type initializer for 'CryptoInitializer' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'System.Security.Cryptography.Native.OpenSsl': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at Interop.CryptoInitializer.EnsureOpenSslInitialized() at Interop.CryptoInitializer..cctor() --- End of inner exception stack trace --- at Interop.CryptoInitializer.Initialize() at Interop.Crypto..cctor() --- End of inner exception stack trace --- at Interop.Crypto.RsaCreate() at System.Security.Cryptography.RSAImplementation.RSAOpenSsl.ImportParameters(RSAParameters parameters) at Microsoft.VisualStudio.Services.Agent.Listener.Configuration.RSAFileKeyManager.GetKey() at Microsoft.VisualStudio.Services.WebApi.VssSigningCredentials.Create(Func`1 factory) at Microsoft.VisualStudio.Services.Agent.Listener.Configuration.OAuthCredential.GetVssCredentials(IHostContext context) at Microsoft.VisualStudio.Services.Agent.Listener.MessageListener.d__11.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Services.Agent.Listener.Agent.d__8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Services.Agent.Listener.Agent.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Services.Agent.Listener.Program.d__1.MoveNext()

macos
xamarin
.net-core
tfs
msbuild
asked on Stack Overflow Dec 16, 2019 by Blanthor • edited Jan 9, 2020 by Blanthor

1 Answer

0

Our on-premises TFS did not have the latest agent binary for OSX, which uses the latest in Mac security instead of using OpenSSL. The new binary is available at github. So I downloaded from there instead of downloading from my TFS server.

answered on Stack Overflow Jan 9, 2020 by Blanthor

User contributions licensed under CC BY-SA 3.0