Configure SAML signing and encryption

This page describes how to configure SAML signing and encryption when your identity provider (IdP) or a local policy requires them. For the complete SAML SSO configuration, refer to SAML authentication.

Most IdPs don't expect authentication requests to be signed, but they often require signed logout requests. If your IdP requires signatures, the Elastic Stack needs a signing key, and you need to give your IdP the corresponding signing certificate so that it can validate them. You can provide the certificate in the Elastic Stack SAML metadata file, or enter it manually in the IdP administration interface.

The Elastic Stack can generate signed SAML authentication and logout messages and process encrypted content, although encryption certificates are rarely needed. You can configure Elasticsearch for signing, encryption, or both, using a single key or individual keys.

Verifying signed messages from the IdP is part of the standard SAML authentication flow. Elasticsearch uses the IdP's signing certificates from the IdP metadata configured in the SAML realm for this verification, which doesn't require an Elasticsearch signing key.

The Elastic Stack uses X.509 certificates with RSA private keys for SAML cryptography. Generate these keys with any standard SSL tool, such as the elasticsearch-certutil tool.

Elasticsearch supports certificates and keys in either PEM, PKCS#12 or JKS format. Some Identity Providers are more restrictive in the formats they support, and require you to provide the certificates as a file in a particular format. You should consult the documentation for your IdP to determine what formats they support.

openssl req -new -x509 -days 3650 -nodes -sha256 -out saml-sign.crt -keyout saml-sign.key
		

Using the elasticsearch-certutil tool, you can generate a signing certificate with the following command. Because PEM format is the most commonly supported format, the example generates a certificate in that format.

bin/elasticsearch-certutil cert --self-signed --pem --days 1100 --name saml-sign --out saml-sign.zip
		

This command does the following:

  • generate a certificate and key pair (the cert subcommand)
  • create the files in PEM format (--pem option)
  • generate a certificate that is valid for 3 years (--days 1100)
  • name the certificate saml-sign (--name option)
  • save the certificate and key in the saml-sign.zip file (--out option)

The generated zip archive contains three files:

  • saml-sign.crt, the public certificate to be used for signing
  • saml-sign.key, the private key for the certificate
  • ca.crt, a CA certificate that is not needed, and can be ignored.

Encryption certificates can be generated with the same process.

By default, Elasticsearch signs all outgoing SAML messages if a signing certificate and key has been configured.

Tip

When configuring a file path in an Elasticsearch setting, keep in mind:

  • In self-managed clusters, file path settings are resolved relative to the Elasticsearch config directory. Elasticsearch monitors this file for changes and reloads the configuration whenever it is updated.
  • If you're using Elastic Cloud Hosted or Elastic Cloud Enterprise, upload the file before referencing it in the configuration. For Elastic Cloud Hosted, upload it as a custom bundle. For Elastic Cloud Enterprise, follow the equivalent ECE procedure.
  • If you're using Elastic Cloud on Kubernetes, install the file as a custom configuration file.

If you want to use PEM formatted keys and certificates for signing, then you should configure the following settings on the SAML realm:

signing.certificate

The path to the PEM formatted certificate file. for example, saml/saml-sign.crt

Note

Only the single leaf certificate is required for the signing.certificate setting, even when using an internal or non-public Certificate Authority (CA). If additional certificates are included, Elasticsearch attempts to validate the resulting chain, and the chain must be valid and complete.

signing.key
The path to the PEM formatted key file. for example, saml/saml-sign.key
signing.secure_key_passphrase

The passphrase for the key, if the file is encrypted. This is a secure setting that must be uploaded to your Elasticsearch keystore.

If you want to use PKCS#12 formatted files or a Java Keystore for signing, then you should configure the following settings on the SAML realm:

signing.keystore.path
The path to the PKCS#12 or JKS keystore. for example, saml/saml-sign.p12
signing.keystore.alias
The alias of the key within the keystore. for example, signing-key
signing.keystore.secure_password
The passphrase for the keystore, if the file is encrypted. This is a secure setting that must be uploaded to your Elasticsearch keystore.

If you want to sign some, but not all outgoing SAML messages, then configure signing.saml_messages with a comma separated list of message types to sign. Supported values are AuthnRequest, LogoutRequest and LogoutResponse and the default value is *.

For example:

xpack:
  security:
    authc:
      realms:
        saml-realm-name:
          order: 2
          ...
          signing.saml_messages: AuthnRequest
          ...
		
  1. This configuration ensures that only SAML authentication requests will be sent signed to the Identity Provider.

Elasticsearch supports a single key for message decryption. If a key is configured, then Elasticsearch attempts to use it to decrypt EncryptedAssertion and EncryptedAttribute elements in Authentication responses, and EncryptedID elements in Logout requests.

Elasticsearch rejects any SAML message that contains an EncryptedAssertion that cannot be decrypted.

If an Assertion contains both encrypted and plain-text attributes, then failure to decrypt the encrypted attributes does not cause an automatic rejection. Rather, Elasticsearch processes the available plain-text attributes (and any EncryptedAttributes that could be decrypted).

Tip

When configuring a file path in an Elasticsearch setting, keep in mind:

  • In self-managed clusters, file path settings are resolved relative to the Elasticsearch config directory. Elasticsearch monitors this file for changes and reloads the configuration whenever it is updated.
  • If you're using Elastic Cloud Hosted or Elastic Cloud Enterprise, upload the file before referencing it in the configuration. For Elastic Cloud Hosted, upload it as a custom bundle. For Elastic Cloud Enterprise, follow the equivalent ECE procedure.
  • If you're using Elastic Cloud on Kubernetes, install the file as a custom configuration file.

If you want to use PEM formatted keys and certificates for SAML encryption, then you should configure the following settings on the SAML realm:

encryption.certificate

The path to the PEM formatted certificate file. for example, saml/saml-crypt.crt

Note

Only the single leaf certificate is required for the encryption.certificate setting, even when using an internal or non-public Certificate Authority (CA). If additional certificates are included, Elasticsearch will attempt to validate the resulting chain, and the chain must be valid and complete.

encryption.key
The path to the PEM formatted key file. for example, saml/saml-crypt.key
encryption.secure_key_passphrase

The passphrase for the key, if the file is encrypted. This is a secure setting that must be uploaded to your Elasticsearch keystore.

If you want to use PKCS#12 formatted files or a Java Keystore for SAML encryption, then you should configure the following settings on the SAML realm:

encryption.keystore.path
The path to the PKCS#12 or JKS keystore. for example, saml/saml-crypt.p12
encryption.keystore.alias
The alias of the key within the keystore. for example, encryption-key
encryption.keystore.secure_password

The passphrase for the keystore, if the file is encrypted. This is a secure setting that must be uploaded to your Elasticsearch keystore.