Skip to content
This repository has been archived by the owner. It is now read-only.

The type initializer for 'libcrypto' threw an exception. ---> System.Security.Cryptography.CryptographicException #1806

Closed
colemickens opened this Issue May 7, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@colemickens
Copy link

colemickens commented May 7, 2015

Used dnx-mono to do dnu restore. Switched to dnx-coreclr-linux-1.0.0-beta5-11722 and tried to run the application:

I attempted install libcrypto++{9,-dev} but that didn't help.

root@14f082acaf9c:/opt/polykube/dotnet# dnvm use coreclr-latest
Adding /root/.dnx/runtimes/dnx-coreclr-linux-x64.1.0.0-beta5-11722/bin to process PATH

root@14f082acaf9c:/opt/polykube/dotnet# cd src/Polykube.Api/

root@14f082acaf9c:/opt/polykube/dotnet/src/Polykube.Api# sleep 99999 | dnx . kestrel
System.IO.FileLoadException: 1A88
File name: 'Polykube.Api, Culture=neutral, PublicKeyToken=null' ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'libcrypto' threw an exception. ---> System.Security.Cryptography.CryptographicException: Error occurred during a cryptographic operation.
   at Interop.libcrypto..cctor()
   --- End of inner exception stack trace ---
   at Interop.libcrypto.EVP_sha1()
   at Internal.Cryptography.HashProviderDispenser.CreateHashProvider(String hashAlgorithmId)
   at System.Security.Cryptography.SHA1.Implementation..ctor()
   at System.Security.Cryptography.SHA1.Create()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Roslyn.Utilities.SHA1CryptoServiceProvider..ctor()
   at Microsoft.CodeAnalysis.CryptographicHashProvider.TryGetAlgorithm(SourceHashAlgorithm algorithmId)
   at Microsoft.CodeAnalysis.Text.SourceText.CalculateChecksum(Stream stream, SourceHashAlgorithm algorithmId)
   at Microsoft.CodeAnalysis.Text.SourceText.From(Stream stream, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, Boolean throwIfBinaryDetected)
   at Microsoft.Framework.Runtime.Roslyn.RoslynCompiler.<>c__DisplayClass14_0.<CreateSyntaxTree>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.<>c__DisplayClass0_0`1.<Get>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.Cache.CreateEntry(Object k, Func`2 acquire)
   at Microsoft.Framework.Runtime.Caching.Cache.<>c__DisplayClass5_0.<AddEntry>b__0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.Framework.Runtime.Caching.Cache.Get(Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.Get[T](ICache cache, Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.Roslyn.RoslynCompiler.CreateSyntaxTree(String sourcePath, CSharpParseOptions parseOptions)
   at Microsoft.Framework.Runtime.Roslyn.RoslynCompiler.GetSyntaxTrees(ICompilationProject project, IEnumerable`1 sourceFiles, IEnumerable`1 sourceReferences, CSharpParseOptions parseOptions, Boolean isMainAspect)
   at Microsoft.Framework.Runtime.Roslyn.RoslynCompiler.CompileProject(ICompilationProject project, ILibraryKey target, IEnumerable`1 incomingReferences, IEnumerable`1 incomingSourceReferences, Func`1 resourcesResolver)
   at Microsoft.Framework.Runtime.Roslyn.RoslynProjectCompiler.CompileProject(ICompilationProject project, ILibraryKey target, Func`1 referenceResolver, Func`1 resourcesResolver)
   at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.<>c__DisplayClass5_0.<GetLibraryExport>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.<>c__DisplayClass0_0`1.<Get>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.Cache.CreateEntry(Object k, Func`2 acquire)
   at Microsoft.Framework.Runtime.Caching.Cache.<>c__DisplayClass5_0.<AddEntry>b__0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.Framework.Runtime.Caching.Cache.Get(Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.Get[T](ICache cache, Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.GetLibraryExport(ILibraryKey target)
   at Microsoft.Framework.Runtime.CompositeLibraryExportProvider.<>c__DisplayClass2_0.<GetLibraryExport>b__0(ILibraryExportProvider r)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Microsoft.Framework.Runtime.CompositeLibraryExportProvider.GetLibraryExport(ILibraryKey target)
   at Microsoft.Framework.Runtime.ProjectExportProviderHelper.GetExportsRecursive(ICache cache, ILibraryManager manager, ILibraryExportProvider libraryExportProvider, ILibraryKey target, Func`2 include)
   at Microsoft.Framework.Runtime.ProjectExportProviderHelper.GetExportsRecursive(ICache cache, ILibraryManager manager, ILibraryExportProvider libraryExportProvider, ILibraryKey target, Boolean dependenciesOnly)
   at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.<>c__DisplayClass5_0.<GetLibraryExport>b__2()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.<>c__DisplayClass5_1.<GetLibraryExport>b__3()
   at Microsoft.Framework.Runtime.Roslyn.RoslynProjectCompiler.CompileProject(ICompilationProject project, ILibraryKey target, Func`1 referenceResolver, Func`1 resourcesResolver)
   at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.<>c__DisplayClass5_0.<GetLibraryExport>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.<>c__DisplayClass0_0`1.<Get>b__0(CacheContext ctx)
   at Microsoft.Framework.Runtime.Caching.Cache.CreateEntry(Object k, Func`2 acquire)
   at Microsoft.Framework.Runtime.Caching.Cache.<>c__DisplayClass5_0.<AddEntry>b__0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Microsoft.Framework.Runtime.Caching.Cache.Get(Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.Caching.CacheExtensions.Get[T](ICache cache, Object key, Func`2 factory)
   at Microsoft.Framework.Runtime.ProjectLibraryExportProvider.GetLibraryExport(ILibraryKey target)
   at Microsoft.Framework.Runtime.CompositeLibraryExportProvider.<>c__DisplayClass2_0.<GetLibraryExport>b__0(ILibraryExportProvider r)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Microsoft.Framework.Runtime.CompositeLibraryExportProvider.GetLibraryExport(ILibraryKey target)
   at Microsoft.Framework.Runtime.LibraryManager.GetLibraryExport(String name, String aspect)
   at Microsoft.Framework.Runtime.Loader.ProjectAssemblyLoader.Load(String name, IAssemblyLoadContext loadContext)
   at Microsoft.Framework.Runtime.Loader.ProjectAssemblyLoader.Load(String name)
   at dnx.host.LoaderContainer.Load(String name)
   at dnx.host.DefaultLoadContext.LoadAssembly(String name)
   at Microsoft.Framework.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(String name, Func`2 factory)
   at Microsoft.Framework.Runtime.Loader.LoadContext.Load(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.AspNet.Hosting.Startup.StartupLoader.FindStartupType(String startupAssemblyName, IList`1 diagnosticMessages)
   at Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureStartup()
   at Microsoft.AspNet.Hosting.Internal.HostingEngine.EnsureApplicationServices()
   at Microsoft.AspNet.Hosting.Internal.HostingEngine.Start()
   at Microsoft.AspNet.Hosting.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
   at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
   at dnx.host.Bootstrapper.RunAsync(List`1 args)
   at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args)
   at dnx.host.RuntimeBootstrapper.Execute(String[] args)
System.TypeInitializationException: The type initializer for 'libcrypto' threw an exception. ---> System.Security.Cryptography.CryptographicException: Error occurred during a cryptographic operation.
   at Interop.libcrypto..cctor()
   --- End of inner exception stack trace ---
   at Interop.libcrypto.EVP_sha1()
   at Internal.Cryptography.HashProviderDispenser.CreateHashProvider(String hashAlgorithmId)
   at System.Security.Cryptography.SHA1.Implementation..ctor()
   at System.Security.Cryptography.SHA1.Create()
System.Security.Cryptography.CryptographicException: Error occurred during a cryptographic operation.
   at Interop.libcrypto..cctor()
@davidfowl

This comment has been minimized.

Copy link
Member

davidfowl commented May 7, 2015

@ellismg

This comment has been minimized.

Copy link
Contributor

ellismg commented May 7, 2015

Does that package provide libcrypto.so?

@colemickens

This comment has been minimized.

Copy link
Author

colemickens commented May 7, 2015

I lost a couple commits, including the one that added libssl-dev to my dev docker container. Looks like that was the missing piece.

@colemickens colemickens closed this May 7, 2015

@ellismg

This comment has been minimized.

Copy link
Contributor

ellismg commented May 7, 2015

Glad you got it sorted out.

@cnblogs-dudu

This comment has been minimized.

Copy link

cnblogs-dudu commented Jun 18, 2015

yum install -y openssl-devel on CentOS.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.