Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8159265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:51:08+00:00 2026-06-06T17:51:08+00:00

I have a valid SAML 2 token from my application IdP: When I try

  • 0

I have a valid SAML 2 token from my application IdP:

When I try to read it using WIF code as below I get the following error:

Cannot read the token from the ‘Response’ element with the ‘urn:oasis:names:tc:SAML:2.0:protocol’ namespace for BinarySecretSecurityToken, with a ” ValueType. If this element is expected to be valid, ensure that security is configured to consume tokens with the name, namespace and value type specified.

Here is the code I am using with a comment showing where it fails

        string certPath = @"G:\Projects\myAPp\SAMLHandlingTests\bin\Debug\SSO.cer";
        X509Certificate2 cert = new X509Certificate2(certPath);
        //X509Certificate2 cert = new X509Certificate2(certPath, "LetMeIn!");


        // Open the SAML
        string samlPath = @"G:\Projects\myAPp\SAMLHandlingTests\bin\Debug\SAML.xml";

        string samlRaw = File.OpenText(samlPath).ReadToEnd();

        XmlReader rdr = XmlReader.Create(samlPath);

        List<System.IdentityModel.Tokens.SecurityToken> tokens = new List<System.IdentityModel.Tokens.SecurityToken>();

        var token = new X509SecurityToken(cert);
        tokens.Add(token);

        SecurityTokenResolver resolver = 
            SecurityTokenResolver.CreateDefaultSecurityTokenResolver(
            new System.Collections.ObjectModel.ReadOnlyCollection<SecurityToken>(tokens), true);

        //Fails on next line!
        SecurityToken securityToken = System.ServiceModel.Security.WSSecurityTokenSerializer.DefaultInstance.ReadToken(rdr, resolver);

        SamlSecurityToken deserializedSaml = securityToken as SamlSecurityToken;

The problem is an XML namespace exception but I don’t know how to ‘ensure that security is configured to consume tokens with the name, namespace and value type specified’

Can someone point me in the right direction please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:51:10+00:00Added an answer on June 6, 2026 at 5:51 pm

    Well I found the issue, it was a SAML Response with Encrypted Assertion which had no type definition as follows:

    The SAML received was as follows:

    <saml:EncryptedAssertion>
    

    when it should have been

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

    It would be possible of course to fix this in my code but the underlying issue was that System.Xml and WIF were not going to let me pass without fully valid xml.

    I hope this helps someone along the way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When my application loops through the first code block below, I get valid data
I have the following function from some legacy code that I am maintaining. long
My problem involves checking if I have a valid database connection before reading from
I have the following in a project named testApp: (testAppViewController is the valid name
I have a function with the following declaration: void cleanValid(int valid[][4], int &size, int
Access token must be valid and contain publish_stream (checked, i do have valid access_token
I have the following XML document: <samlp:LogoutRequest ID=123456789 Version=2.0 IssueInstant=200904051217> <saml:NameID>@NOT_USED@</saml:NameID> <samlp:SessionIndex>abcdefg</samlp:SessionIndex> </samlp:LogoutRequest> I'd
I have valid data in jquery, how to I loop every item I get
I have following valid JSON to Parse: [{name:kkkk,empid:55628,address:mumbai,mobile:9525878558},{name:xtreme,empid:20,address:stripes,mobile:9999597},{name:xtreme,empid:20,address:stripes,mobile:9699597},{name:xtreme,empid:20,address:stripes,mobile:9699597},{name:xtreme,empid:20,address:stripes,mobile:9699597},{name:xtreme,empid:20,address:stripes,mobile:9689597},{name:xtreme,empid:20,address:stripes,mobile:9699597},{name:xtreme,empid:20,address:stripes,mobile:9689597},{name:xtreme,empid:20,address:stripes,mobile:9699597},{name:vx,empid:96,address:addre,mobile:9999596},{name:vxx,empid:96,address:addre,mobile:96899},{name:vx,empid:96,address:addre,mobile:9689596}] After parsing this I want to
I have a Facebook application where I authorize the user using the PHP SDK.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.