asp.net-mvc – DotNetOpenAuth:消息签名不正确

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – DotNetOpenAuth:消息签名不正确前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
尝试使用MyOpenID和Yahoo进行身份验证时,我会收到一条“消息签名不正确”异常.

我几乎使用了DotNetOpenAuth 3.4.2附带的ASP.NET MVC示例代码

  1. public ActionResult Authenticate(string openid)
  2. {
  3. var openIdRelyingParty = new OpenIdRelyingParty();
  4. var authenticationResponse = openIdRelyingParty.GetResponse();
  5.  
  6. if (authenticationResponse == null)
  7. {
  8. // Stage 2: User submitting identifier
  9. Identifier identifier;
  10.  
  11. if (Identifier.TryParse(openid,out identifier))
  12. {
  13. var realm = new Realm(Request.Url.Root() + "openid");
  14. var authenticationRequest = openIdRelyingParty.CreateRequest(openid,realm);
  15. authenticationRequest.RedirectToProvider();
  16. }
  17. else
  18. {
  19. return RedirectToAction("login","home");
  20. }
  21. }
  22. else
  23. {
  24. // Stage 3: OpenID provider sending assertion response
  25. switch (authenticationResponse.Status)
  26. {
  27. case AuthenticationStatus.Authenticated:
  28. {
  29. // TODO
  30. }
  31. case AuthenticationStatus.Failed:
  32. {
  33. throw authenticationResponse.Exception;
  34. }
  35. }
  36. }
  37.  
  38. return new EmptyResult();
  39. }

与Google,AOL等人合作.但是,雅虎和MyOpenID属于AuthenticationStatus.Failed案例,但出现以下异常:

  1. DotNetOpenAuth.Messaging.Bindings.InvalidSignatureException: Message signature was incorrect.
  2. at DotNetOpenAuth.OpenId.ChannelElements.SigningBindingElement.ProcessIncomingMessage(IProtocolMessage message) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OpenId\ChannelElements\SigningBindingElement.cs:line 139
  3. at DotNetOpenAuth.Messaging.Channel.ProcessIncomingMessage(IProtocolMessage message) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\Channel.cs:line 992
  4. at DotNetOpenAuth.OpenId.ChannelElements.OpenIdChannel.ProcessIncomingMessage(IProtocolMessage message) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OpenId\ChannelElements\OpenIdChannel.cs:line 172
  5. at DotNetOpenAuth.Messaging.Channel.ReadFromRequest(HttpRequestInfo httpRequest) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\Channel.cs:line 386
  6. at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.GetResponse(HttpRequestInfo httpRequestInfo) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OpenId\RelyingParty\OpenIdRelyingParty.cs:line 540

显示其他人有同样的问题:http://trac.dotnetopenauth.net:8000/ticket/172

有没有人有解决方法

解决方法

事实证明,这是在Web场环境中使用DotNetOpenAuth的问题.

当您创建OpenIdRelyingParty时,请确保在构造函数中传递null.

这将使您的网站进入OpenID无状态或“哑”模式.用户登录稍慢一些(如果您注意到),但您避免不必编写一个IRelyingPartyApplicationStore来允许DotNetOpenAuth在您的农场中工作;

  1. var openIdRelyingParty = new OpenIdRelyingParty(null);

猜你在找的asp.Net相关文章