SAML Signature Basics
SAML Responses are protected with XML Signatures. This page covers how signatures are structured, what to check when verifying them, and how to run certificate operations safely.
๐ Signature Structure
Signatures live under ds:Signature and may target the Assertion or the entire Response. Verification uses the IdP-provided X.509 certificate.
Core elements
- ๐ The target can be the Assertion or the full Response (sometimes both).
- ๐ Signature is stored in ds:Signature and verified with an X.509 certificate.
- ๐ A wrong Reference URI (scope) causes verification to fail.
๐ก๏ธ Verification Tips
Check not only the signature itself but also the conditions and certificate state.
Common checks
- โ Time drift causes NotBefore / NotOnOrAfter failures.
- โ Audience must match the expected EntityID.
- โ Ensure the signature covers the expected element (Assertion/Response).
- โ Watch for expired or malformed certificates.
Certificate operations
- ๐ Track rotation schedules and update metadata in advance.
- ๐ Use CRL/OCSP if provided to check revocation.
- ๐ If key pinning is used, deploy new keys in the right order to avoid lockouts.
- ๐ Keep test and production certificates separate to avoid mix-ups.
๐งฏ Common Errors and Fixes
Signature failures have recurring patterns; knowing them speeds up troubleshooting.
Typical cases
- โ ๏ธ Signature verification errors: wrong certificate, wrong reference, possible tampering.
- โ ๏ธ XML parsing errors: Deflate/Base64 decoding failures.
- โ ๏ธ Condition mismatch: time drift or audience mismatch.
How to troubleshoot
- ๐งญ Check the Reference URI and certificate fingerprint shown in logs.
- ๐งญ Verify NTP/timezone to rule out clock skew.
- ๐งญ Re-import IdP/SP metadata to eliminate mismatches.
SubjectConfirmation / Conditions checks
SubjectConfirmation (especially Bearer) and Conditions must be validated; mismatches mean the assertion is not intended for the recipient.
- SubjectConfirmationData Recipient matches the ACS URL.
- NotBefore/NotOnOrAfter are within the current time window.
- Conditions > AudienceRestriction matches the expected EntityID.