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

Comments

Projects
None yet
3 participants
@bryanmacfarlane
Member

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: dotnet/cli#3964 (comment)

@bryanmacfarlane

This comment has been minimized.

Show comment
Hide comment
@bryanmacfarlane

bryanmacfarlane Aug 2, 2016

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@joshka

joshka 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.

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

This comment has been minimized.

Show comment
Hide comment
@bryanmacfarlane

bryanmacfarlane Aug 2, 2016

Member

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

Member

bryanmacfarlane commented Aug 2, 2016

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

@bryanmacfarlane

This comment has been minimized.

Show comment
Hide comment
@bryanmacfarlane

bryanmacfarlane Aug 4, 2016

Member

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/
Member

bryanmacfarlane commented Aug 4, 2016

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

This comment has been minimized.

Show comment
Hide comment
@joshka

joshka 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.

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

This comment has been minimized.

Show comment
Hide comment
@bryanmacfarlane

bryanmacfarlane Aug 4, 2016

Member

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.

Member

bryanmacfarlane commented Aug 4, 2016

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

This comment has been minimized.

Show comment
Hide comment
@joshka

joshka 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 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

This comment has been minimized.

Show comment
Hide comment
@joshka

joshka Aug 4, 2016

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

joshka commented Aug 4, 2016

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

@bryanmacfarlane

This comment has been minimized.

Show comment
Hide comment
@bryanmacfarlane

bryanmacfarlane Aug 4, 2016

Member

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

Member

bryanmacfarlane commented Aug 4, 2016

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

This comment has been minimized.

Show comment
Hide comment
@bryanmacfarlane

bryanmacfarlane Aug 14, 2016

Member

I updated the docs

Member

bryanmacfarlane commented Aug 14, 2016

I updated the docs

@davibe

This comment has been minimized.

Show comment
Hide comment
@davibe

davibe 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

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