DEV Community

Daniele Michelin
Daniele Michelin

Posted on Originally published at daniele-michelin.com

SAML: signature validation failed in Nextcloud

Nextcloud (user_saml with php-saml) could not verify the SAML response signature with the stored IdP certificate and rejects the login.

Common causes

  • The identity provider (Entra ID, ADFS, Keycloak) rotated its signing certificate and Nextcloud still has the old one.
  • The wrong certificate is stored, e.g. the encryption instead of the signing certificate.
  • Signature settings do not match: Nextcloud expects signed assertions while the IdP only signs the response (or vice versa).
  • The certificate was damaged while copying (line breaks, missing characters).

How to check it

Show the SAML configuration in Nextcloud

sudo -u www-data php /var/www/nextcloud/occ saml:config:get
Enter fullscreen mode Exit fullscreen mode

Read the current IdP certificates from the metadata

curl -s https://sso.example.com/realms/main/protocol/saml/descriptor | grep -o '<ds:X509Certificate>[^<]*'
Enter fullscreen mode Exit fullscreen mode

Fingerprint and expiry of the stored certificate

openssl x509 -in idp.crt -noout -fingerprint -sha256 -enddate
Enter fullscreen mode Exit fullscreen mode

What actually helps

  1. Paste the current signing certificate from the IdP metadata into Nextcloud's SSO settings (Base64 block only, no blank lines).
  2. Align signature options with the IdP, e.g. signed assertions vs. signed response.
  3. For planned rotations, add the new certificate in time if the IdP uses both in parallel.

FAQ

Is this about the website's TLS certificate?

No. SAML uses a separate signing certificate from the IdP. Nextcloud's HTTPS certificate plays no role here.

Why did it work yesterday?

Almost always the IdP certificate was renewed. Entra ID and ADFS rotate automatically; compare the fingerprint in the metadata with the one in Nextcloud.


Full page with every command and the German/Italian version: daniele-michelin.com/en/errors/nextcloud-saml-signature-validation-failed/

First published at daniele-michelin.com. The error lexicon covers HTTP, DNS, TLS, mail, database, PHP, nginx, systemd and Nextcloud, in German, English and Italian.

Top comments (2)

Collapse
 
userxnom profile image
Abdullah Naseer •

The FAQ answer is the most useful line in the post, Daniele — "Why did it work yesterday? Almost always the IdP certificate was renewed." That is the whole failure mode: Entra ID and ADFS rotate automatically, nothing alerts the admin, and the first person to discover it is a user who cannot log in.

The one thing I would add is a check that runs before that moment. Your fingerprint commands are exactly the right comparison — stored certificate versus IdP metadata — but as written they are something you run after the failure. A scheduled version of the same comparison, even a weekly script that fetches the metadata, extracts the signing certificate and compares its SHA-256 fingerprint with the stored one, turns a login outage into a warning a few days early. In your support work, which of these do you actually see most often — the rotation nobody noticed, or the wrong certificate pasted in, encryption instead of signing?

Collapse
 
mikweb2025design profile image
Daniele Michelin •

Thanks, that's exactly the gap. The fingerprint check in the post is a post-mortem tool, and the same comparison on a schedule turns it into an early warning. Entra ID even publishes the upcoming certificate in the federation metadata before it becomes active. So a weekly job that diffs the metadata's signing certs against the stored fingerprint catches the rotation days ahead, not at the first failed login.

From what I see in support, the unnoticed rotation is clearly the most common case. It's also the most frustrating one, because nothing changed on the SP side and everyone starts by debugging the wrong system. The encryption-vs-signing mix-up does happen, but it fails right away during setup, so it gets caught before go-live. Rotation is the one that breaks things in production on a random Tuesday.

I'll add a short "monitor it" section with a cron-ready snippet to the post. Good call.