runtime: Unable to load DLL 'System.Security.Cryptography.Native' on OS X
We’re using .Net Core RC2 to build a desktop app with Web UI. It works fine on developer mac, but does not start on a clean OS X 10.11, producing 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.Crypto.GetMaxMdSize()
at Interop.Crypto..cctor()
TypeInitializationException: The type initializer for 'Crypto' threw an exception.
Interop.Crypto.EvpSha1()
Internal.Cryptography.HashProviderDispenser.CreateHashProvider(String hashAlgorithmId)
System.Security.Cryptography.SHA1.Implementation..ctor()
Microsoft.AspNetCore.Razor.RazorTemplateEngine.ComputeChecksum(Stream inputStream)
Microsoft.AspNetCore.Razor.RazorTemplateEngine.GenerateCode(Stream inputStream, String className, String rootNamespace, String sourceFileName)
Microsoft.AspNetCore.Mvc.Razor.Internal.RazorCompilationService.Compile(RelativeFileInfo file)
Microsoft.AspNetCore.Mvc.Razor.Internal.CompilerCache.CreateCacheEntry(String normalizedPath, Func`2 compile)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Razor.Internal.CompilerCache.GetOrAdd(String relativePath, Func`2 compile)
Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(String relativePath)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet`1 expirationTokens, String relativePath, Boolean isMainPage)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.OnCacheMiss(ViewLocationExpanderContext expanderContext, ViewLocationCacheKey cacheKey)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext actionContext, String pageName, Boolean isMainPage)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage)
Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage)
Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult)
Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.FilterActionInvoker.<InvokeResultAsync>d__44.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.FilterActionInvoker.<InvokeResultFilterAsync>d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
Microsoft.AspNetCore.Mvc.Internal.FilterActionInvoker.<InvokeAllResultFiltersAsync>d__42.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.FilterActionInvoker.<InvokeResourceFilterAsync>d__37.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
Microsoft.AspNetCore.Mvc.Internal.FilterActionInvoker.<InvokeAsync>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler.<InvokeActionAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
Looks like this is caused by openssl dependency. Can it be bundled with the app somehow, so that users don’t have to install openssl separately?
The app is built using
dotnet build --runtime osx.10.11-x64 --framework netcoreapp1.0
dotnet publish --runtime osx.10.11-x64 --framework netcoreapp1.0
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 23 (12 by maintainers)
Release note contents:
OS X has an external dependency on OpenSSL
.NET Core uses OpenSSL as the provider for cryptographic primitives and the SSL/TLS protocol. While there is a pre-installed version of OpenSSL on OS X 10.11, that version is no longer supported, and is not used by .NET Core. In order to satisfy the OpenSSL dependency,
libcrypto.1.0.0.dylibandlibssl.1.0.0.dylibmust be loadable via rpath probing. One such way of satisfying this requirement is via Homebrew:When this dependency is not met, an application making direct or indirect use of cryptography will get an exception similar to
System.DllNotFoundException: Unable to load DLL 'System.Security.Cryptography.Native': The specified module could not be found..A note on producing standalone OS X applications
Since .NET Core loads libcrypto and libssl via rpath probing these libraries can be copied into the working directory of an application before being copied to another machine. But when trying to use this configuration users should be advised that the Homebrew version of libssl has an absolute path dependency on libcrypto. The local copy of libssl may need to be modified to search for libcrypto via rpath with the install_name_tool utility.
Hello! I have this same issue but i am running on an Ubuntu 16 system.
Please Help!
I’m using macports, and because
DYLD_LIBRARY_PATHsometimes does not work in El Capitan, I manage to do workaround by making libcrypto and libssl symlink to corefx directory.And
dotnetcli runs as expected. Here’s my version@danmosemsft Yep, there should already be a step that does it, but it probably calls
brew link --force openssl, which doesn’t work anymore. (The fact that machine setup isn’t failing when it does that is a sign of a bug in infrastructure). Instead it needs to follow the steps on https://www.microsoft.com/net/core#macos (though with themkdir /usr/local/libthat we haven’t added on that page).Hi
The command below works for me 100% of the time, for the moment, with MacOS X 10.11.6, macports and dotnet core version
1.0.0-preview2-003131:Please, note the variable only affects the
dotnetcommand.HTH!