brew upgrade
brew install openssl
brew link --force openssl
dotnet new
Should create a new dotnet app
dotnet --info
output:
What is the output of brew link --force openssl
?
Try running all brew
commands using sudo
(sudo brew install openssl
, sudo brew link --force openssl
). That did it on my machine.
Any resolution here? I'm having the same issue on a new install
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()
--- End of inner exception stack trace ---
at Interop.Crypto..cctor()
--- End of inner exception stack trace ---
at Interop.Crypto.GetRandomBytes(Byte* buf, Int32 num)
at System.IO.Path.GetCryptoRandomBytes(Byte* bytes, Int32 byteCount)
at System.IO.Path.GetRandomFileName()
at Microsoft.DotNet.InternalAbstractions.TemporaryDirectory..ctor()
at Microsoft.Extensions.EnvironmentAbstractions.DirectoryWrapper.CreateTemporaryDirectory()
at Microsoft.DotNet.Configurer.NuGetPackagesArchiver..ctor()
at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel)
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
at Microsoft.DotNet.Cli.Program.Main(String[] args)
Abort trap: 6
brew upgrade openssl
Error: openssl 1.0.2h_1 already installed
brew link -f openssl
Warning: Already linked: /opt/boxen/homebrew/Cellar/openssl/1.0.2h_1
To relink: brew unlink openssl && brew link openssl
/cc @ellismg
@bartonjs
https://github.com/dotnet/cli/issues/3964
brew don't link openssl1.0.2 , install openssl1.0.1 and link it
Great news...
I saw some updated instructions on https://www.microsoft.com/net/core and with a bit of tweaking to where my precise home-brew dirs are located, things are now working...
echo $(brew --prefix)
# Use that path for ...
ln -s /path/to/homebrew/cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /path/to/homebrew/cellar/openssl/1.0.2h_1/lib/libssl.1.0.0.dylib /usr/local/lib/
Did you have to uninstall and re-install afterwards? I"m still getting the same error:
Scotts-Mac-mini:local sdw$ ln -s /usr/local/cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dylib /usr/local/lib/
Scotts-Mac-mini:local sdw$ ln -s /usr/local/cellar/cellar/openssl/1.0.2h_1/lib/libssl.1.0.0.dylib /usr/local/lib/
Scotts-Mac-mini:local sdw$ cd lib
Scotts-Mac-mini:lib sdw$ ls
dtrace libicuio.a libicutest.dylib
icu libicuio.dylib libicutu.57.1.dylib
libcrypto.1.0.0.dylib libicule.57.1.dylib libicutu.57.dylib
libicudata.57.1.dylib libicule.57.dylib libicutu.a
libicudata.57.dylib libicule.a libicutu.dylib
libicudata.a libicule.dylib libicuuc.57.1.dylib
libicudata.dylib libiculx.57.1.dylib libicuuc.57.dylib
libicui18n.57.1.dylib libiculx.57.dylib libicuuc.a
libicui18n.57.dylib libiculx.a libicuuc.dylib
libicui18n.a libiculx.dylib libssl.1.0.0.dylib
libicui18n.dylib libicutest.57.1.dylib node_modules
libicuio.57.1.dylib libicutest.57.dylib pkgconfig
libicuio.57.dylib libicutest.a
Scotts-Mac-mini:lib sdw$ dotnet new
The type initializer for 'Crypto' threw an exception.
Scotts-Mac-mini:lib sdw$
Bump, I'm seeing the same error as the original poster:
dotnet restore
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()
--- End of inner exception stack trace ---
at Interop.Crypto..cctor()
--- End of inner exception stack trace ---
at Interop.Crypto.GetRandomBytes(Byte* buf, Int32 num)
at System.IO.Path.GetCryptoRandomBytes(Byte* bytes, Int32 byteCount)
at System.IO.Path.GetRandomFileName()
at Microsoft.DotNet.InternalAbstractions.TemporaryDirectory..ctor()
at Microsoft.Extensions.EnvironmentAbstractions.DirectoryWrapper.CreateTemporaryDirectory()
at Microsoft.DotNet.Configurer.NuGetPackagesArchiver..ctor()
at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel)
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
at Microsoft.DotNet.Cli.Program.Main(String[] args)
Abort trap: 6
@Tombo890 DId you perform the install and symlinking instructions from https://www.microsoft.com/net/core#macos? Or, if you use Homebrew but don't use default install paths, https://github.com/dotnet/cli/issues/3783#issuecomment-239511681 gives more hints for dealing with custom setup.
Yeah, I performed the linking mentioned on both Microsoft's page and in this thread, can see that when executing again or navigating to the path:
@bartonjs, thanks for the quick reply! Anything else I should try? Brew path is the default path
@Tombo890 I like to use otool -L
to verify that the links (which might be pointing to other links, etc) are fully resolved (and pointing to the valid-looking binaries):
bartonjs@jsb-mac:~/coreclr $ otool -L /usr/local/lib/libssl.1.0.0.dylib
/usr/local/lib/libssl.1.0.0.dylib:
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/Cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
bartonjs@jsb-mac:~/coreclr $ otool -L /usr/local/lib/libcrypto.1.0.0.dylib
/usr/local/lib/libcrypto.1.0.0.dylib:
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
bartonjs@jsb-mac:~/coreclr $ otool -L /usr/local/lib/libssl.1.0.0.dylib
/usr/local/lib/libssl.1.0.0.dylib:
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/Cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
If it reports "No such file or directory" for either file then something in the symlink chain is broken. Or if (for example) the first line for the libssl entry says it's really libcrypto on the inside, then that could be a different problem.
After that, the only thing I'd know to check is launching the app under dtruss to trace what failure actually occurred in library loading; but that's a pretty big jump, unfortunately.
@bartonjs, good tip! looks like something is off, looking into this now:
IMAGE in /usr/local/lib
± |master ✓| → otool -L /usr/local/lib/libssl.1.0.0.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: '/usr/local/lib/libssl.1.0.0.dylib': No such file or directory.
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: internal objdump command failed
IMAGE in /usr/local/lib
± |master ✓| → otool -L /usr/local/lib/libcrypto.1.0.0.dylib
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: '/usr/local/lib/libcrypto.1.0.0.dylib': No such file or directory.
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: internal objdump command failed
Jobs:vscode Uthen$ ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln: /usr/local/lib//libcrypto.1.0.0.dylib: File exists
Jobs:vscode Uthen$
Don't work on my MAC
Just to update the forum on my solution. I was able to get things working on OS X by removing the symbolic links mentioned above, deleting the files, re-installing openssl through home-brew, then recreating the symlink.
execute
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/
instead of
ln -s /usr/local/Cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dylib /usr/local/lib
ln -s /usr/local/Cellar/openssl/1.0.2h_1/lib/libssl.1.0.0.dylib /usr/local/lib
if you receive "File exists" message ln -sf will do the magic..
ln -sf /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -sf /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
SudhaOnline solution worked for me, seems like it might break other things though, so use with caution.
SudhaOnline, it works for me too.
Sudhaonline thanks a lot your solution worked.
@blackdwarf do we need to update the docs here?
@piotrpMSFT the docs on https://www.microsoft.com/net/core#macos already use the solution from @SudhaOnline's reply, so I would say "no".
SudhaOnline, it worked well, best solution, thanks
Most helpful comment
execute
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/
instead of
ln -s /usr/local/Cellar/openssl/1.0.2h_1/lib/libcrypto.1.0.0.dylib /usr/local/lib
ln -s /usr/local/Cellar/openssl/1.0.2h_1/lib/libssl.1.0.0.dylib /usr/local/lib
if you receive "File exists" message ln -sf will do the magic..
ln -sf /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -sf /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/