Prompt
How do I troubleshoot SAML assertion errors in my app?
Latest observation
Troubleshooting SAML assertion errors usually comes down to checking the assertion contents, signatures/certificates, timestamps, audience/recipient values, and your app’s configuration.
Here’s a practical checklist:
1) Capture the raw SAML response
- Use browser dev tools, a SAML-tracing browser extension, or IdP logs.
- Decode the
SAMLResponse(Base64) and inspect:IssuerSubject/NameIDConditionsAudienceRestrictionRecipientInResponseToNotBefore/NotOnOrAfter- Signature elements
2) Check time-related errors
Common failure: assertion expired or not yet valid.
- Verify your server clock and IdP clock are synchronized (NTP).
- Confirm your app allows a small clock skew (often 2–5 minutes).
- Check:
NotBeforeis not in the futureNotOnOrAfterhas not passed
3) Validate issuer, audience, and recipient
These must exactly match what your app expects.
- Issuer: must match the IdP entity ID
- AudienceRestriction: must include your SP entity ID / audience URI
- Recipient: must match your ACS URL exactly
- Watch for:
- trailing slashes
- HTTP vs HTTPS
- custom ports
- environment mismatch (dev vs prod)
4) Verify signature and certificates
Common issues:
- IdP rotated its signing certificate
- Your app is validating against the wrong cert
- The assertion/response is signed with a cert your app doesn’t trust
Check:
- Is the response signed, assertion signed, or both?
- Is the cert in metadata current?
- Did the IdP recently rotate keys?
- Is your app expecting SHA-256 but receiving something else?
(Old SHA-1 setups can also cause issues depending on libraries/policies.)
5) Ensure NameID and attributes are what your app expects
Sometimes the assertion is valid, but your app rejects it because user mapping fails.
- Confirm expected
NameIDformat:emailAddresspersistenttransient
- Verify required attributes exist and are named correctly:
emailuidgivenNamesn
- Check for case sensitivity and namespace/attribute name mismatches.
6) Check binding and endpoint configuration
- Make sure the IdP is posting to the correct ACS endpoint.
- Confirm your app expects the same binding:
- HTTP-POST
- HTTP-Redirect
- Verify RelayState handling if your app depends on it.
7) Look for common app/library errors
Examples:
- “Invalid signature”
- “Audience restriction failed”
- “Assertion has expired”
- “Recipient mismatch”
- “InResponseTo does not match”
- “Unknown issuer”
- “No signed assertion found”
These messages usually point directly to the failing check.
8) Compare working and failing assertions
If you have a known-good login and a failing one:
- Diff the two decoded assertions
- Look for differences in:
- entity IDs
- ACS URL
- signature algorithm
- NameID format
- attributes
- time conditions
9) Test with a SAML tool or validator
Useful tools:
- SAML tracer browser extension
- Online SAML decoders/inspectors
- Your library’s debug logging
- IdP/SP metadata validators
10) Enable verbose logs in your SAML library
Turn on debug logging for the SAML component you use. Libraries often show the exact validation step that failed.
Quick mapping of error → likely cause
- Invalid signature → wrong cert, rotated cert, tampered assertion, trust config issue
- Audience mismatch → wrong SP entity ID or environment
- Recipient mismatch → wrong ACS URL
- Assertion expired → clock skew or short validity window
- Unknown issuer → incorrect IdP entity ID/metadata
- Missing attribute → IdP claim mapping/config issue
- InResponseTo invalid → request/response mismatch or state lost
If you want, I can help you debug a specific SAML error message or walk through a sample decoded assertion.