Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSX: An error occurred: The type initializer for 'Crypto' threw an exception. #470

Closed
bryanmacfarlane opened this issue Aug 2, 2016 · 11 comments
Assignees

Comments

@bryanmacfarlane
Copy link
Collaborator

bryanmacfarlane commented Aug 2, 2016

net core depends on updated openssl on OSX.

A recent change in brew makes force link fail.

Net core issue: https://github.com/dotnet/cli/issues/3964#issuecomment-236493536

@bryanmacfarlane
Copy link
Collaborator Author

bryanmacfarlane commented Aug 2, 2016

Current proposed solution.

brew update
brew install openssl

From the root of the agent after download and extract (I will likely bake into cfg later).
Note I didn't need sudo here (would be interested in others experience)

install_name_tool -add_rpath /usr/local/opt/openssl/lib ./bin/System.Security.Cryptography.Native.dylib

If it already exists for some reason -delete_repath with same args can be used. This tells the net core crypt dylib we distribute to use the openssl brew just installed.

@joshka
Copy link

joshka commented Aug 2, 2016

@bryanmacfarlane sudo was only necessary for the dotnet installation as it installs the crypto lib to a directory that is only writeable by root.

@bryanmacfarlane
Copy link
Collaborator Author

bryanmacfarlane commented Aug 2, 2016

@joshka Thanks for confirming! I verified no sudo for our usage as well.

@bryanmacfarlane
Copy link
Collaborator Author

net core updated it's instructions:

https://www.microsoft.com/net/core#macos

brew update
brew install openssl
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/

@joshka
Copy link

joshka commented Aug 4, 2016

Those instructions are somewhat erroneous. They will work, but leave your system in an inconsistent state. The above mechanism is better IMO.

@bryanmacfarlane
Copy link
Collaborator Author

Thanks for the note. Can you clarify more on the erroneous state? I have a conversation going with the net core folks so details are appreciated.

@joshka
Copy link

joshka commented Aug 4, 2016

There's an error repro on the original issue 597 in homebrew core iirc. Either way, a local change makes more sense to fix this than a global one

@joshka
Copy link

joshka commented Aug 4, 2016

The homebrew guys would give a better indication on what's the full problem here.

@bryanmacfarlane
Copy link
Collaborator Author

Yes. The problem is a key scenarios for us will be building net core apps (and calling dotnet). So, folks will do the dotnet instructions in order for it to work

@bryanmacfarlane
Copy link
Collaborator Author

I updated the docs

@davibe
Copy link

davibe commented Apr 20, 2017

In order to avoid linking openssl to system paths (which could cause problems) this is what we ended up doing

brew update
brew install openssl
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib .
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib .
export DYLD_LIBRARY_PATH=$(pwd)

then ./configure.sh, ./run.sh, etc. will work just fine

This also means you could embed the correct openssl version in the package and adjust DYLD_LIBRARY_PATH in the *.sh scripts making it all self-contained

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants