DotNet Core “Unable to load DLL ‘System.Security.Cryptography.Native” error

I was trying to play with DotNet Core in Visual Studio Code, and I was following the instructions as stated here.

After installed Brew I installed the latest version of OpenSSL as required by DotNet Core and then I tried to run the classic “Hello World” program, but the command

dotnet restore

failed with this error:

“Unable to load DLL ‘System.Security.Cryptography.Native”

This error has to do with OpenSSL, or even better with Brew that refuseed to correctly link OpenSSL.

Here is the correct command sequence that needs to correctly setting up OpenSSL for DotNet Core.

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/
ln -s /usr/local/Cellar/openssl/1.0.2j/bin/openssl openssl

Hope this helps