SecurityTokenSignatureKeyNotFoundException when validating JWT signature
The problem is nestled in the exception message here:
Clause[0] = X509ThumbprintKeyIdentifierClause(Hash = 0xF8A59280B3D13777CC7541B3218480984F421450)
The token is signed with the default key identifier clause for an X.509 certificate: its thumbprint. The metadata is exposing just the RSA parameters and a name identifier. When the client retrieves the metadata, it sets up an RSA key using this information, not an X.509 thumbprint.
To correct this error, the signing credentials have to be changed to include the correct name identifier:
var credentials = new X509CertificateCredentials(
cert,
new SecurityKeyIdentifier(
new NamedKeySecurityKeyIdentifierClause(
"kid",
"F8A59280B3D13777CC7541B3218480984F421450")));
This includes the expected identifier in the signature, and the signature is validated successfully.