Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Html.AntiForgeryToken helper throws exception on Mono #847

Closed
Praburaj opened this issue Jul 23, 2014 · 4 comments
Closed

Html.AntiForgeryToken helper throws exception on Mono #847

Praburaj opened this issue Jul 23, 2014 · 4 comments
Assignees
Milestone

Comments

@Praburaj
Copy link
Contributor

https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.Core/AntiForgery/BinaryBlob.cs#L96

private static byte[] GenerateNewToken(int bitLength)
        {
            var data = new byte[bitLength / 8];
            CryptRand.FillBuffer(new ArraySegment<byte>(data));
            return data;
        }
System.DllNotFoundException: bcrypt.dll
  at (wrapper managed-to-native) Microsoft.AspNet.Security.DataProtection.UnsafeNativeMethods:BCryptGenRandom (intptr,byte*,uint,Microsoft.AspNet.Security.DataProtection.BCryptGenRandomFlags)
  at Microsoft.AspNet.Security.DataProtection.BCryptUtil.GenRandom (System.Byte* buffer, Int32 bufferBytes) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Security.DataProtection.CryptRand.FillBuffer (ArraySegment`1 buffer) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.BinaryBlob.GenerateNewToken (Int32 bitLength) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.BinaryBlob..ctor (Int32 bitLength) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.AntiForgeryToken.get_SecurityToken () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.TokenProvider.GenerateFormToken (Microsoft.AspNet.Http.HttpContext httpContext, System.Security.Claims.ClaimsIdentity identity, Microsoft.AspNet.Mvc.AntiForgeryToken cookieToken) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.AntiForgeryWorker.GetTokens (Microsoft.AspNet.Http.HttpContext httpContext, Microsoft.AspNet.Mvc.AntiForgeryToken oldCookieToken) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.AntiForgeryWorker.GetFormInputElement (Microsoft.AspNet.Http.HttpContext httpContext) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.AntiForgery.GetHtml (Microsoft.AspNet.Http.HttpContext context) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.Rendering.HtmlHelper.AntiForgeryToken () [0x00000] in <filename unknown>:0 
  at ASP.Views_StoreManager_Edit_cshtml+<ExecuteAsync>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.Razor.RazorView+<RenderPageCoreAsync>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.Razor.RazorView+<RenderPageAsync>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.Razor.RazorView+<RenderAsync>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.ViewResult+<ExecuteResultAsync>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.ReflectedActionInvoker+<InvokeActionResult>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.ReflectedActionInvoker+<InvokeActionResultFilter>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.ReflectedActionInvoker+<InvokeActionResultWithFilters>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.ReflectedActionInvoker+<InvokeActionAsync>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Mvc.MvcRouteHandler+<RouteAsync>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Routing.Template.TemplateRoute+<RouteAsync>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Routing.RouteCollection+<RouteAsync>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.Builder.RouterMiddleware+<Invoke>d__1.MoveNext () [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0 
  at MusicStore.Startup+<<Configure>b__6>d__0.MoveNext () [0x00000] in <filename unknown>:0 

Recommendation from Levi:
MVC should instead be using the RandomNumberGenerator class. CryptRand was just a temporary workaround because the CLR team didn’t have the crypto libraries ported over.

@Praburaj Praburaj added the bug label Jul 23, 2014
@Praburaj
Copy link
Contributor Author

@harshgMSFT

@yishaigalatzer yishaigalatzer added this to the 6.0.0-alpha3 milestone Jul 23, 2014
@yishaigalatzer
Copy link
Contributor

@harshgMSFT please go ahead and make the change (preferably this week)

@harshgMSFT
Copy link
Contributor

Prabu can you please verify and close?

@Praburaj
Copy link
Contributor Author

This can be closed. If this is the same as the private that I tested, I can confirm this worked.

dougbu added a commit that referenced this issue Aug 1, 2014
…)` return `string`

- fixes #566 and part of #847
- allows compositions such as `@Html.Label("property", Html.Id("property"))`
  and `@Html.Raw(Html.DisplayText("property"))` (this one is not recommended)
- adjust XML comments to match
- add missing XML comments to `HtmlHelperValueExtensions`
- nit: `TInnerModel` -> `TModelItem`

- increase XML comment consistency for changed methods
 - generally make wording more consistent e.g. how we use words such as
   "returns"
 - use `<see langref="string|true|false|null"/>` more
dougbu added a commit that referenced this issue Aug 2, 2014
…)` return `string`

- fixes #566 and part of #847
- allows compositions such as `@Html.Label("property", Html.Id("property"))`
  and `@Html.Raw(Html.DisplayText("property"))` (this one is not recommended)
- adjust XML comments to match
- add missing XML comments to `HtmlHelperValueExtensions`
- nit: `TInnerModel` -> `TModelItem`

- increase XML comment consistency for changed methods
 - generally make wording more consistent e.g. how we use words such as
   "returns"
 - use `<see langref="string|true|false|null"/>` more
dougbu added a commit that referenced this issue Aug 5, 2014
- don't call other extension methods
- #847 line 7
- remove extension methods that do nothing but pass through to the interface method
 - weren't exactly ambiguous (interface method wins) but were useless
dougbu added a commit that referenced this issue Aug 5, 2014
- #847 line 7 sub-bullets
- don't call extension methods from our templates
 - partially addressed in PR #934 (for methods changed there)
- don't reference extension methods from XML comments
dougbu added a commit that referenced this issue Aug 6, 2014
- don't call other extension methods
- #847 line 7
- remove extension methods that do nothing but pass through to the interface method
 - weren't exactly ambiguous (interface method wins) but were useless
dougbu added a commit that referenced this issue Aug 6, 2014
- #847 line 7 sub-bullets
- don't call extension methods from our templates
 - partially addressed in PR #934 (for methods changed there)
- don't reference extension methods from XML comments
dougbu added a commit that referenced this issue Aug 9, 2014
- #847 line 1: copy XML comments from interfaces to extension methods
- lots of wording changes to be more consistent
 - core text split from PR #866, where @rynowak and I hashed out the words
 - to extent possible, reuse words between method descriptions

- add `<remarks>` describing behaviour of input helpers e.g. `CheckBox()`
- add a few missing `<param/>` and `<typeparam/>` elements and fill in empty ones
- display more HTML elements as tags
- use `<c>true|false|null</c>` more often

nits:
- "The expression" -> "An expression"
- make examples for `ObjectToDictionary()` and `AnonymousObjectToHtmlAttributes()` more consistent
- move `<typeparam/>` elements (that existed) after all `<param/>` elements
dougbu added a commit that referenced this issue Aug 12, 2014
- #847 line 1: copy XML comments from interfaces to extension methods
- lots of wording changes to be more consistent
 - core text split from PR #866, where @rynowak and I hashed out the words
 - to extent possible, reuse words between method descriptions

- add `<remarks>` describing behaviour of input helpers e.g. `CheckBox()`
- add a few missing `<param/>` and `<typeparam/>` elements and fill in empty ones
- display more HTML elements as tags
- use `<c>true|false|null</c>` more often

nits:
- "The expression" -> "An expression"
- make examples for `ObjectToDictionary()` and `AnonymousObjectToHtmlAttributes()` more consistent
- move `<typeparam/>` elements (that existed) after all `<param/>` elements
dougbu added a commit that referenced this issue Aug 12, 2014
- #847 line 1: copy XML comments from interfaces to extension methods
- lots of wording changes to be more consistent
 - core text split from PR #866, where @rynowak and I hashed out the words
 - to extent possible, reuse words between method descriptions

- add `<remarks>` describing behaviour of input helpers e.g. `CheckBox()`
- add a few missing `<param/>` and `<typeparam/>` elements and fill in empty ones
- display more HTML elements as tags
- use `<c>true|false|null</c>` more often

nits:
- "The expression" -> "An expression"
- make examples for `ObjectToDictionary()` and `AnonymousObjectToHtmlAttributes()` more consistent
- move `<typeparam/>` elements (that existed) after all `<param/>` elements
dougbu added a commit that referenced this issue Aug 14, 2014
- #847 line 1: copy XML comments from interfaces to extension methods
- lots of wording changes to be more consistent
 - core text split from PR #866, where @rynowak and I hashed out the words
 - to extent possible, reuse words between method descriptions

- add a few missing `<param/>` and `<typeparam/>` elements and fill in empty ones
- display more HTML elements as tags
- use `<c>true|false|null</c>` more often
- add `<remarks/>` describing behaviour of input helpers e.g. `CheckBox()`
- add `<remarks/>` explaining "renders"
- add `<remarks/>` containing example expression names

nits:
- "The expression" -> "An expression"
- make examples for `ObjectToDictionary()` and `AnonymousObjectToHtmlAttributes()` more consistent
- move `<typeparam/>` elements (that existed) after all `<param/>` elements
- explain "checked" attributes better, removing some duplicated words from the `RadioButton[For]()` descriptions
- correct `routeValues` description in `GenerateForm()` comments
@danroth27 danroth27 changed the title Html.AntiForgeryToken helper throws exception on mono Html.AntiForgeryToken helper throws exception on Mono Aug 17, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants