ACS75005“该请求不是有效的SAML2协议消息。”当我使用SAML连接到Windows Azure Active Directory时始终显示 [英] ACS75005 "The request is not a valid SAML2 protocol message." Is showing always when I connect to Windows Azure Active Directory using SAML

查看:158
本文介绍了ACS75005“该请求不是有效的SAML2协议消息。”当我使用SAML连接到Windows Azure Active Directory时始终显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Windows Azure Active Directory用作Web应用程序中的IdP。我的代码可以在其他SAML IdP上正常运行,但是仅在Windows Azure AD中提供以下消息!

I'm trying to consume Windows Azure Active Directory as an IdP in a web application. My code works fine on other SAML IdPs but gives the following message in the Windows Azure AD only !!


登录

Sign in

很抱歉,我们无法登录。

Sorry, but we're having trouble signing you in.

我们收到了错误的请求。
其他技术信息:

We received a bad request. Additional technical information:

跟踪ID:8377e605-6b9f-47be-8547-5fce7f4285af

Trace ID:8377e605-6b9f-47be-8547-5fce7f4285af

时间戳记:2014-08-04 13:31:27Z

Timestamp: 2014-08-04 13:31:27Z

ACS75005:

该请求无效SAML2协议消息。

The request is not a valid SAML2 protocol message.

我替换了代码,并使用了Microsoft发布的SAML请求此处,仅替换了一些值,但仍收到相同的错误消息!

I replaced my code and used the SAML request that Microsoft published here and replaced only some values but still getting the same error message !!

我的请求出了什么问题?以及如何获得有关消息的更多详细信息!

What is wrong with my request? And how can I get more details about the message !

知道我的应用程序是在Windows Azure AD应用程序中定义的。

Knowing that my application is defined in the Windows Azure AD applications.

<samlp:AuthnRequest xmlns="urn:oasis:names:tc:SAML:2.0:metadata" ID="_56dbfeac-107a-46d2-b989-651f90107312" Version="2.0" IssueInstant="2014-08-04T13:28:05Z" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
  <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">SOMETHING</Issuer> 
</samlp:AuthnRequest>

编辑001
将断言编辑为Dushyant之后建议,它变为:

Edit 001 After editing the assertion to be as Dushyant suggested, it becomes:

<samlp:AuthnRequest xmlns="urn:oasis:names:tc:SAML:2.0:assertion" 
    ID="_efcebb45-5ee6-42df-ace4-a343f28f5a46"                                                 
    Version="2.0" IssueInstant="2014-08-07T06:29:09Z"                                                 
    xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">                                    
    <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">SOMETHING</Issuer>
</samlp:AuthnRequest>

但是仍然显示相同的错误!

But still the same error is showing!

也请在此处找到我正在使用的测试项目。 。仅将Webconfig中AppSettings中的值替换为您的SAML设置。

Also please find the test project I'm using here. Only replace the values in the AppSettings in the webconfig for your SAML settings.

推荐答案

使用

xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"

代替xmlns = urn:oasis:names:tc:SAML:2.0:metadata

instead of xmlns="urn:oasis:names:tc:SAML:2.0:metadata"

我相信你遵循我们在此处记录的内容: http://msdn.microsoft.com /en-us/library/azure/dn195589.aspx 。如果是这样,则您在该文章中发现了一个错误-对此感到抱歉。

I believe you followed what we've document here: http://msdn.microsoft.com/en-us/library/azure/dn195589.aspx. If so, you've found a bug in that article - sorry about that.

希望这会有所帮助。

Homam,我检查了您的代码。问题在于AuthnRequest的编码方式。我将其更改为标准deflate编码,并且可以使用。

Homam, I reviewed your code. The problem was with the way the AuthnRequest was being encoded. I changed it to standard deflate encoding and it worked.

public string GetAzureRequest(AuthRequestFormat format)
{
    string xml = @"<samlp:AuthnRequest xmlns=""urn:oasis:names:tc:SAML:2.0:assertion"" ID=""#ID""
                                     Version=""2.0"" IssueInstant=""#DATE""
                                     xmlns:samlp=""urn:oasis:names:tc:SAML:2.0:protocol"">
                        <Issuer xmlns=""urn:oasis:names:tc:SAML:2.0:assertion"">#ISSUER</Issuer>
                 </samlp:AuthnRequest>";

    xml = xml.Replace("#DATE", issue_instant);
    xml = xml.Replace("#ID", id);
    xml = xml.Replace("#ISSUER", appSettings.Issuer);
    xml = xml.Replace("\r\n", "");

    if (format == AuthRequestFormat.Base64)
    {
        /*COMMENTED THIS OUT*/

        //byte[] toEncodeAsBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(requestDocument.OuterXml);
        //string result = System.Convert.ToBase64String(toEncodeAsBytes);
        //return result;


        /*ADDED THIS*/

        MemoryStream memoryStream = new MemoryStream();
        StreamWriter writer = new StreamWriter(new DeflateStream(memoryStream, CompressionMode.Compress, true), new UTF8Encoding(false));
        writer.Write(xml);
        writer.Close();
        string result = Convert.ToBase64String(memoryStream.GetBuffer(), 0, (int)memoryStream.Length, Base64FormattingOptions.None);
        return result;
    }

    return null;
}

这篇关于ACS75005“该请求不是有效的SAML2协议消息。”当我使用SAML连接到Windows Azure Active Directory时始终显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆