gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 05:12:19 25 4
gpt4 key购买 nike

尝试使用 MyOpenID 和 Yahoo 进行身份验证时,出现“消息签名不正确”异常。

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

public ActionResult Authenticate(string openid)
{
var openIdRelyingParty = new OpenIdRelyingParty();
var authenticationResponse = openIdRelyingParty.GetResponse();

if (authenticationResponse == null)
{
// Stage 2: User submitting identifier
Identifier identifier;

if (Identifier.TryParse(openid, out identifier))
{
var realm = new Realm(Request.Url.Root() + "openid");
var authenticationRequest = openIdRelyingParty.CreateRequest(openid, realm);
authenticationRequest.RedirectToProvider();
}
else
{
return RedirectToAction("login", "home");
}
}
else
{
// Stage 3: OpenID provider sending assertion response
switch (authenticationResponse.Status)
{
case AuthenticationStatus.Authenticated:
{
// TODO
}
case AuthenticationStatus.Failed:
{
throw authenticationResponse.Exception;
}
}
}

return new EmptyResult();
}

与 Google、AOL 和其他公司合作良好。但是,Yahoo 和 MyOpenID 属于 AuthenticationStatus.Failed 情况,但有以下异常(exception):

DotNetOpenAuth.Messaging.Bindings.InvalidSignatureException: Message signature was incorrect.
at DotNetOpenAuth.OpenId.ChannelElements.SigningBindingElement.ProcessIncomingMessage(IProtocolMessage message) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OpenId\ChannelElements\SigningBindingElement.cs:line 139
at DotNetOpenAuth.Messaging.Channel.ProcessIncomingMessage(IProtocolMessage message) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\Channel.cs:line 992
at DotNetOpenAuth.OpenId.ChannelElements.OpenIdChannel.ProcessIncomingMessage(IProtocolMessage message) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\OpenId\ChannelElements\OpenIdChannel.cs:line 172
at DotNetOpenAuth.Messaging.Channel.ReadFromRequest(HttpRequestInfo httpRequest) in c:\Users\andarno\git\dotnetopenid\src\DotNetOpenAuth\Messaging\Channel.cs:line 386
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

有人有解决办法吗?

最佳答案

事实证明,这是在网络场环境中使用 DotNetOpenAuth 时出现的问题。

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

这会将您的网站置于 OpenID 无状态或“哑”模式。用户登录的速度稍慢(如果您注意到的话),但您不必编写 IRelyingPartyApplicationStore 来允许 DotNetOpenAuth 在您的服务器场中工作;

var openIdRelyingParty = new OpenIdRelyingParty(null);

关于asp.net-mvc - DotNetOpenAuth:消息签名不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2505565/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com