The Identity Provider (IdP) and the Service Provider (SP) each provide their own SAML certificate. The specific roles and responsibilities for generating and managing these certificates are dependent on which system is sending or receiving a SAML message during the Single Sign-On (SSO) process. The exchange of these certificates typically occurs during the initial setup via a standardized metadata file.
Core concepts: IdP vs. SP
In a SAML-based SSO workflow, two main entities communicate with each other:
- Identity Provider (IdP): This is the system that authenticates the user's identity, such as a company's SSO portal or a service like Okta, Azure AD, or PingFederate.
- Service Provider (SP): This is the application or service the user is trying to access, such as Salesforce, Google Workspace, or another SaaS application.
IdP-provided certificates: For signing assertions
The most common and critical use of a SAML certificate is for the IdP to digitally sign the "SAML assertion". The assertion is the XML-based message that the IdP sends to the SP to confirm the user's successful authentication.
- Who generates it? The IdP itself generates its own signing certificate. If you use a third-party IdP like Okta or Azure AD, their system creates and manages the certificate for you. For a self-hosted solution, an administrator would generate a self-signed certificate using tools like OpenSSL.
- What is it used for? The IdP uses its private key to sign the assertion. The corresponding public key is then given to the SP.
- Who receives it? The Service Provider receives and stores the IdP's public certificate.
- How is it used? When the SP receives a SAML assertion, it uses the IdP's public key to verify the digital signature, ensuring the message was not tampered with and that it legitimately came from the trusted IdP.
SP-provided certificates: For signing requests and encryption
While less common for basic configurations, Service Providers may also use certificates for enhanced security measures.
- Signing authentication requests: An SP may sign its initial authentication request (
AuthnRequest) to the IdP. This is done to verify that the request originated from a legitimate SP and has not been altered. In this scenario, the SP would provide its public certificate to the IdP for verification. - Encrypting assertions: To protect sensitive data within the SAML assertion (such as user attributes), the IdP can encrypt the assertion before sending it.
- Who provides the certificate? The Service Provider provides its public "encryption certificate" to the IdP during the initial setup.
- How is it used? The IdP uses the SP's public key to encrypt the sensitive parts of the assertion. Only the SP can decrypt this information using its corresponding private key.
How certificates are exchanged and managed
The most efficient way to exchange SAML certificates and other configuration details is through metadata.
- Metadata file exchange: During the initial setup, both the IdP and SP generate a metadata XML file containing all necessary configuration information, including their public certificate(s) and endpoint URLs. These files are exchanged between the two parties, automating most of the manual setup.
- Automated rotation: Many modern SAML providers support automatic metadata exchange, where the SP or IdP can monitor a specific URL for updates. This simplifies the process of rotating certificates before they expire, preventing any disruption to SSO services.
- Manual updates: If automated metadata exchange is not supported, administrators must manually download the new certificate or metadata file and upload it to the other provider before the old one expires.
Key differences: SAML certificates vs. TLS/SSL certificates
It is important to differentiate between SAML certificates and the Transport Layer Security (TLS/SSL) certificates that secure HTTPS traffic.
| Feature | SAML Certificate | TLS/SSL Certificate |
|---|---|---|
| Purpose | To verify the authenticity and integrity of SAML messages, and optionally to encrypt data within them. | To secure the communication channel between a web browser and a server via HTTPS. |
| Issuer | Most commonly self-signed by the IdP or SP themselves. For production, a Certificate Authority (CA)-signed certificate may be used. | Typically issued by a trusted third-party Certificate Authority (CA), like DigiCert or Let's Encrypt. |
| Verification | The public certificate is manually exchanged and configured between the IdP and SP. | The browser automatically checks the trust chain of the certificate to a known, trusted CA. |
| Scope | Ensures trust between the IdP and SP systems. | Ensures a secure connection between the user's browser and the web server. |