SendSsoAsync fails to send SAMl Response

I am hitting a strange problem, wherein the SendSsoAsync() shown below is failing to send SAML Response to SP. It throws 500 Internal Server Error

Can you please advise what could be possible set of reasons, and how I can debug this. How can enable full debug(by componentspace).

thank you

private Task CompleteSsoAsync(string samlUserSubjectName)

// The user is logged in (authenticated) at the identity provider(middleware at this instance).
// Respond to the authn request by sending a SAML response containing a SAML assertion to the SP.
return _samlIdentityProvider.SendSsoAsync(samlUserSubjectName, attributes);


The best option is to enable the SAML trace.
If you’re not sure what the issue is, please email the log file to