> ## Documentation Index
> Fetch the complete documentation index at: https://stytch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# SAML Signing Certificates

When sending an authentication request to the IdP, Stytch sends a signature along with the request, indicating that the request came from Stytch. This signature can be verified using the Signing Certificate provided by Stytch, in the form of an [X.509 certificate](https://en.wikipedia.org/wiki/X.509). This certificate is present on all [SAML Connection Objects](/docs/api-reference/b2b/api/sso/saml-connection-object).

Some IdPs may call this a "signed request" or "signature validation", or have `WantAuthnRequestsSigned="true"` in their SAML configuration settings. This certificate should be uploaded to the IdP in order to make use of this optional feature.

You can update the signing certificate for a SAML connection by providing a PKCS1 format RSA private key (starting with `-----BEGIN RSA PRIVATE KEY-----`) in the [Update SAML Connection](/docs/api-reference/b2b/api/sso/saml/update-saml-connection) endpoint. Stytch will automatically generate a new X.509 certificate from this private key and return it in the `signing_certificates` array. This private key will also be used to sign future [SAML SSO Authenticate Start](/docs/api-reference/b2b/api/sso/shared/start-sso-authenticate) requests.

### Verification Certificates

When receiving an authentication response from the IdP, Stytch will verify that the response actually originates from the IdP.

Stytch will only accept an authentication response from the IdP if the signature of the response is correctly validated with the connection's stored Verification Certificate, which comes from the IdP. This X.509 certificate is uploaded to Stytch and stored with the specific SAML connection. In the API, you can provide the certificate on a [SAML update request](/docs/api-reference/b2b/api/sso/saml/update-saml-connection).

There is a limit of 5 verification certificates per SAML connection. You can delete a connection's certificate by calling the [Delete Verification Certificate](/docs/api-reference/b2b/api/sso/saml/delete-saml-verification-certificate) endpoint.

When uploading a certificate to an IdP or passing a certificate to Stytch, you may encounter the certificate in the form of a PEM file. The signing certificate from Stytch's [Create SAML Connection](/docs/api-reference/b2b/api/sso/saml/create-saml-connection) endpoint is provided as a raw string with newlines.

```bash theme={null}
echo $SIGNING_CERTIFICATE > stytch_signing_certificate.pem
```

### Encryption Private Keys

Some identity providers encrypt SAML assertions using a public key. To allow Stytch to decrypt these responses, you can upload the corresponding RSA private key in PKCS1 format via the [Update SAML Connection](/docs/api-reference/b2b/api/sso/saml/update-saml-connection) endpoint using the `saml_encryption_private_key` field. Each key appears in the `saml_encryption_private_keys` array on the [SAML Connection object](/docs/api-reference/b2b/api/sso/saml-connection-object).

To remove a key, call the [Delete Encryption Private Key](/docs/api-reference/b2b/api/sso/saml/delete-encryption-private-key) API endpoint. Stytch supports up to five encryption private keys per connection so you can rotate keys without downtime.

<Panel>
  ```text OBJECT x509 theme={null}
  -----BEGIN CERTIFICATE-----
  MIIFIjCCAwoCCQC8brjOdUXVjTANBgkqhkiG9w0BAQsFADBTMQswCQYDVQQGEwJV
  UzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzEX
  MBUGA1UECgwOU3R5dGNoIEVYQU1QTEUwHhcNMjMwMjA5MjMwMjA0WhcNMjQwMjA5
  MjMwMjA0WjBTMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQG
  A1UEBwwNU2FuIEZyYW5jaXNjbzEXMBUGA1UECgwOU3R5dGNoIEVYQU1QTEUwggIi
  MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDIRzEMPwjJgflImAYjSIfDMXCC
  IBFhuhxY8/mnidMiMauGR+dEMP4Jlg8oOZSNMx8wfPH7aqRIM8dkj8BhJ3QUjQmA
  XLSgYsBUSSMaELHCurPSdz+rHfUMfD/cag5GeyPM2KtBD3I/Du545SNeURwKaiB5
  fwlfYblMGNFvB70KRpl/YkvBYL7knKTGe1K6NG56IyGhRguEpaksxBJ4RTXcNiWr
  ENcrw88LUpJd+7cDTlLB+6N+hPWUS/91R5kbQw/GX23C6uUDxTtGimWvA+riV6OF
  IjWf5oDWioZj9wUFXElw+mMmTYye/cIHtXlwia845dWD5Gn9o5hpXoPBzV9tNPce
  FgUcaczFkyRpnPU6HwMNFkfGPYWyn8w1mW6DKCNwe6gG9PYejoTMsvIrsoB4e5mT
  Y56ZbYZRCglzBOgQZZejxZfvhg5m027lNrAdr5keBF3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