Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Salesforce by (11.9k points)

I've implemented SSO using Spring SAML and everything is working fine. It worked with the following IDP's till now: 1) 2)

Now I'm testing with as my Identity Provider. As there is no provision to upload Service Provider Metadata I've done the following configuration settings at its IdP:

Gave my entityID and Assertion Consumer Service URL. I also uploaded my SP certificate. I've downloaded its metadata (idp metadata) which is as follows (hiding the sensitive information):

<?xml version="1.0" encoding="UTF-8"?><md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:ds="" entityID="" validUntil="2024-04-11T13:55:57.307Z">

<md:IDPSSODescriptor WantAuthnRequestsSigned="true" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">

  <md:KeyDescriptor use="signing">








  <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location=""/>

  <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location=""/>

Now when I tried to test my SP, first it redirected me to the IDP(salesforce) asking for credentials where I entered them but then after that I was redirected back to my Assertion consumer Service URL(which is my SP) but here an exception was generated saying that

HTTP Status 401 - This request requires HTTP authentication(Authentication Failed: Incoming SAML message is invalid).

I've tried the following but didn't work :( - Though not necessary, I've downloaded the certificate file from the salesforce and imported it to my keystore.jks so that to make sure that key is used for signature validation.(Not necessary due to the certificate info already present in IDP metadata).

Here is what I found in my log file(Adding necessary info only after successful AuthnRequest):



Attempting to extract credential from an X509Data

Found 1 X509Certificates

Found 0 X509CRLs

Single certificate was present, treating as end-entity certificate

Credentials successfully extracted from child {}X509Data by provider

A total of 1 credentials were resolved

Registry could not locate evaluable criteria for criteria class

Attempting to validate signature using key from supplied credential

Creating XMLSignature object

Validating signature with signature algorithm URI:

Validation credential key algorithm 'RSA', key instance class ''

Signature validated with key from supplied credential

Signature validation using candidate credential was successful

Successfully verified signature using KeyInfo-derived credential

Attempting to establish trust of KeyInfo-derived credential

Failed to validate untrusted credential against trusted key

Failed to establish trust of KeyInfo-derived credential

Failed to verify signature and/or establish trust using any KeyInfo-derived credentials

Attempting to verify signature using trusted credentials

Attempting to validate signature using key from supplied credential

Creating XMLSignature object

Validating signature with signature algorithm URI:

Validation credential key algorithm 'RSA', key instance class ''

Signature did not validate against the credential's key

Signature validation using candidate validation credential failed

org.opensaml.xml.validation.ValidationException: Signature did not validate against the credential's key

at org.opensaml.xml.signature.SignatureValidator.validate(

at org.opensaml.xml.signature.impl.BaseSignatureTrustEngine.verifySignature(

at org.opensaml.xml.signature.impl.ExplicitKeySignatureTrustEngine.validate(

at org.opensaml.xml.signature.impl.ExplicitKeySignatureTrustEngine.validate(








at org.opensaml.saml2.binding.decoding.BaseSAML2MessageDecoder.decode(













at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(

at org.springframework.web.filter.DelegatingFilterProxy.doFilter(

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(

at org.apache.catalina.core.ApplicationFilterChain.doFilter(

at org.apache.catalina.core.StandardWrapperValve.invoke(

at org.apache.catalina.core.StandardContextValve.invoke(

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(

at org.apache.catalina.core.StandardHostValve.invoke(

at org.apache.catalina.valves.ErrorReportValve.invoke(

at org.apache.catalina.core.StandardEngineValve.invoke(

at org.apache.catalina.connector.CoyoteAdapter.service(

at org.apache.coyote.http11.Http11Processor.process(

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(


at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(

at java.util.concurrent.ThreadPoolExecutor$


Failed to verify signature using either KeyInfo-derived or directly trusted credentials

Validation of protocol message signature failed for context issuer '', message type: {urn:oasis:names:tc:SAML:2.0:protocol}Response

Authentication request failed: Incoming SAML message is invalid

Updated SecurityContextHolder to contain null Authentication

Delegating to authentication failure handler[email protected]153a591

Can someone please tell me what is going wrong by looking at the above log. Any help would be highly appreciated.

1 Answer

0 votes
by (32.1k points)

It looks like your IDP is using a different key for digital signatures than it represents in the metadata.

You should investigate the SAML message you received and look for element X509Certificate inside element Signature. Extract the content of the certificate into an individual file, e.g. sales-force-sign.cer.

Or, you can just add the key which extracted from the message into your IDP metadata. You can manually update the XML file and add another KeyDescriptor with use="signing". It might be faster to do.

To learn in-depth about Workflow in Salesforce, sign up for an industry based Salesforce developer certification.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94k users

Browse Categories