I had .NET Core working just fine on my Mac a few days ago. Today, it no longer works:
Unhandled Exception: 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': The specified module could not be found.
(Exception from HRESULT: 0x8007007E)
at Interop.CryptoInitializer.EnsureOpenSslInitialized()
at Interop.CryptoInitializer..cctor()
A few things have changed since a few days ago and today.
brew update, and was greeted with this:"Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!
Homebrew no longer needs to have ownership of /usr/local."
- I don't think I did anything out of the ordinary.
- How do I get back in to a working state?
Brew says I am running OpenSSL, 1.0.2j. I followed the instructions of https://github.com/dotnet/core/blob/master/cli/known-issues.md, but this doesn't work. brew now refuses to do it:
brew link --force openssl
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
Environment:
.NET Command Line Tools (1.0.0-preview2-003121)
Product Information:
Version: 1.0.0-preview2-003121
Commit SHA-1 hash: 1e9d529bc5
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.12
OS Platform: Darwin
RID: osx.10.12-x64
cc @bartonjs
@vcsjones I've added notes on how to get past this here: https://github.com/dotnet/corefx/issues/9012#issuecomment-247495589
@vcsjones https://github.com/dotnet/coreclr/blob/master/Documentation/building/osx-instructions.md#openssl
You should just need the mkdir and the first two symlinks. If you want to build corefx on your Mac then you'll also need the other 3 symlinks. This is a very reduced form of what brew link did; it's the parts we cared about (which doesn't include the reasons why they disabled it for openssl).
Thanks. I'm back up and running. A little birdy also told me there might be an effort underway to move away from OpenSSL on OS X and move toward CommonCrypto / Security Transforms, which would be hugely appreciated.
Most helpful comment
@vcsjones https://github.com/dotnet/coreclr/blob/master/Documentation/building/osx-instructions.md#openssl
You should just need the mkdir and the first two symlinks. If you want to build corefx on your Mac then you'll also need the other 3 symlinks. This is a very reduced form of what
brew linkdid; it's the parts we cared about (which doesn't include the reasons why they disabled it for openssl).