Metadata, certificates, and key rollover
Cedar Inc. and the training service agree on names, addresses and keys before Avery's first sign-in, and they write that agreement down as metadata. Keys still have to change, and changing one without breaking every sign-in takes an overlap planned in advance.
Agreeing before the first sign-in
Before Avery's first sign-in to the training service, an administrator at each organization had to enter the other side's details: entity ID, endpoints, binding, certificateA signed statement that a public key belongs to a name, such as a website's hostname, for stated purposes and a limited period. A certificate authority signs it, so software that trusts the authority can connect the key to the name.. Typing them by hand invites mistakes, and a single wrong character in an ACSThe endpoint at a SAML service provider that receives the identity provider's response, usually as a form the browser posts. The service provider publishes its ACS URL in metadata, and the identity provider sends responses only there. address is enough to break every sign-in. So each side publishes its details as one XML document, its metadata, and the other side imports it. Here is Cedar Inc.'s, with the certificate shortened:
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
entityID="https://login.cedar.example"
validUntil="2026-11-12T00:00:00Z" cacheDuration="PT24H">
<md:IDPSSODescriptor WantAuthnRequestsSigned="true"
protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<md:KeyDescriptor use="signing">
<ds:KeyInfo><ds:X509Data>
<ds:X509Certificate>MIIDBzCCAe+gAwIBAgIUQm3x...</ds:X509Certificate>
</ds:X509Data></ds:KeyInfo>
</md:KeyDescriptor>
<md:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
Location="https://login.cedar.example/saml/slo"/>
<md:NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:persistent</md:NameIDFormat>
<md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
Location="https://login.cedar.example/saml/sso"/>
</md:IDPSSODescriptor>
</md:EntityDescriptor>entityID is Cedar Inc.'s name. The role descriptor, here IDPSSODescriptor, says it acts as an identity providerA service that authenticates users and tells other applications about the sign-in, so those applications never handle the users' passwords. In OpenID Connect it is called an OpenID Provider. for single sign-onSigning in once and then using several applications without entering credentials again, usually because they all rely on the same identity provider., and WantAuthnRequestsSigned says it expects signed requests. The KeyDescriptor with use="signing" holds the certificate whose public keyThe half of a key pair that can be shared freely. It checks signatures made with the matching private key and can encrypt data that only that private key can decrypt. verifies its signatures. Each endpoint pairs a binding with a location, as SAML bindings showed.
The training service's metadata has the same shape with an SPSSODescriptor instead:
<md:SPSSODescriptor AuthnRequestsSigned="true" WantAssertionsSigned="true"
protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<md:KeyDescriptor use="signing">...</md:KeyDescriptor>
<md:KeyDescriptor use="encryption">...</md:KeyDescriptor>
<md:AssertionConsumerService index="0" isDefault="true"
Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
Location="https://training.example/saml/acs"/>
</md:SPSSODescriptor>AuthnRequestsSigned says the training service signs its requests, with the key in its own signing KeyDescriptor. WantAssertionsSigned asks Cedar Inc. to sign assertions. The encryption key is the one Cedar Inc. would use for an encrypted assertion. The ACS list is the full set of addresses where Cedar Inc. may deliver responses.
A certificate carries a public key
SAMLThe Security Assertion Markup Language, a federation standard widely used for workplace single sign-on, in which the identity provider sends the application a signed assertion about the user. metadata almost always wraps each public key in an X.509 certificate, but uses it differently from a website. A browser checking https://login.cedar.example walks the server's certificate up to a certificate authorityAn organization that checks who controls a name and then signs certificates for it. Browsers and other software trust a chosen set of authorities, and through them the certificates those authorities issue. it trusts and checks dates and names, as Validating a certificate showed. A SAML service providerSAML's name for the application that relies on an identity provider's sign-in, which OpenID Connect calls a relying party. In SCIM, the same term means the application that stores the accounts. usually does none of that. Cedar Inc.'s signing certificate is often self-signed, and what matters is the public key inside it: the training service trusts that key because it came through the agreement, not because a certificate authority vouched for it.
That has a practical consequence. Many SAML implementations ignore the certificate's expiry date, so an "expired" signing certificate can keep working for years. Others enforce the date and break on the day it passes. The two organizations should know which kind they run, because it decides whether a certificate's end date is a deadline or merely a reminder.
The key in the metadata is public. Cedar Inc. keeps the matching private keyThe half of a key pair that its owner keeps to themselves and uses to create signatures or decrypt data. Anyone who obtains it can act as its owner., often in a hardware security module, the protected key storage from Storing and using keys. Whoever holds that private key can write assertions any service provider will accept for any of Cedar Inc.'s users, which is why its protection matters more than almost any other secret Cedar Inc. has.
Metadata you can trust
The training service's administrator fetches Cedar Inc.'s metadata from https://login.cedar.example/saml/metadata. HTTPSHTTP protected by TLS, so traffic is encrypted and checked for changes while it travels. It protects the connection, but does not prove that the site at the other end is honest. proves the document came from that host, but not that the host is the one Cedar Inc. meant, or that whoever controls it is entitled to name signing keys. A metadata URLA web address, such as https://photos.example/api/albums/42?limit=10. It names how to connect (https), the domain, the path to a particular page or resource, and any extra parameters after the question mark. quietly changed in a configuration, or a compromised web server, would hand the training service an attacker's key.
Metadata therefore needs its own trust path. One is a careful first exchange: the administrators confirm the certificate's fingerprint over a separate channel before importing it. Another is signed metadata: the EntityDescriptor carries an XML signatureA value made with a private key that lets anyone holding the matching public key check that a message came from the key's holder and has not been changed. It proves origin and integrity; it does not hide the message. from a key the receiver already trusts. Large federations, such as those connecting universities, publish one signed aggregate holding thousands of entity descriptors, and each member checks the federation's signature before using any of them.
validUntil sets a hard end: after 12 November 2026, this document must not be used. cacheDuration suggests how often to fetch a fresh copy, here daily. A receiver that refreshes metadata automatically should check the signature on every copy, keep the last good one if a fetch fails, and stop when validUntil passes rather than trusting stale keys forever.
Changing the signer without breaking everyone
Cedar Inc. plans to replace its signing key. If it simply switched to a new key one morning, every service provider still holding the old certificate would refuse every sign-in. The safe order adds the new key to the trust before anyone uses it:
| Stage | Cedar Inc. signs with | The training service trusts |
|---|---|---|
| Before | Old key | Old key |
| Publish | Old key | Old and new keys |
| Switch | New key | Old and new keys |
| Retire | New key | New key |
To publish, Cedar Inc. adds a second KeyDescriptor use="signing" to its metadata. Every service provider must take in the new key, whether by refreshing metadata or by an administrator's change, before Cedar Inc. switches. How long that takes is the hard part: a federation that refreshes daily needs a day or two, while a partner who pins certificates by hand may need weeks of notice. After the switch, the old key stays trusted long enough for responses already in flight to finish, a few minutes, and then Cedar Inc. removes it, and service providers remove it too.
The service provider's own keys
The training service has keys too, and their safe order is different because the roles are reversed.
Its encryption key is used by Cedar Inc. to encrypt assertions, and by the training service to decrypt them. Here the training service must be ready first. It generates the new key pair and makes sure its software can decrypt with both old and new private keys. Only then does it publish the new public key in its metadata. Cedar Inc. starts encrypting to the new key whenever it refreshes, which the training service cannot control, so it keeps decrypting with the old key until it is sure no response encrypted to it can still arrive, and only then removes the old key from its metadata and deletes it.
Its request-signing key follows the identity provider's pattern instead, because now the training service is the signer. It publishes the new certificate alongside the old one, waits until Cedar Inc. trusts both, switches to signing requests with the new key, and retires the old certificate. Mixing up the two orders is a common cause of outages: an SP that publishes a new encryption key before it can decrypt with it breaks every sign-in the moment the IdP refreshes.
Expiry and compromise need different responses
A planned rollover has time for overlap. A compromised private key does not. If Cedar Inc.'s signing key leaked, anyone holding it could sign assertions for any user, so the old key must leave every service provider's trust at once, even if some sign-ins fail while the new key spreads. Cedar Inc. would also need to work out which sessions were opened with forged assertions, which no signature check can tell after the fact. Extending a certificate's end date, or issuing a new certificate for the same key, does nothing to repair a compromise.
For any change, keep a record of what changed and when: the certificate fingerprints, which side published what, and when each receiver confirmed it trusts the new key. Then test both directions. A response signed with the new key should be accepted, and once the old key is retired, a response signed with it should be refused. A rollover that never tests the refusal has not finished.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Prepare trust before a SAML signing-key changeRead Lab Photos' SAML metadata, then rehearse a signing-key rollover in the safe order: publish, overlap, switch and retire, and see the retired key refused.