Skip to content

Commit

Permalink
Add logging to assertion decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersAbel committed Dec 18, 2020
1 parent 65d8d2c commit 6f8966b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Sustainsys.Saml2/SAML2P/Saml2Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,17 +466,20 @@ private IEnumerable<XmlElement> RetrieveAssertionElements(IOptions options)
assertions.AddRange(encryptedAssertions.Decrypt(serviceCertificate.PrivateKey)
.Select(xe => (XmlElement)xe.GetElementsByTagName("Assertion", Saml2Namespaces.Saml2Name)[0]));
decrypted = true;
options.SPOptions.Logger.WriteVerbose($"Assertion decryption succeeded using {serviceCertificate.Thumbprint}");
break;
}
catch (CryptographicException)
catch (CryptographicException ex)
{
options.SPOptions.Logger.WriteVerbose($"Assertion decryption using {serviceCertificate.Thumbprint} failed: {ex.Message}");
// we cannot depend on Idp's sending KeyInfo, so this is the only
// reliable way to know we've got the wrong cert
}
}
if (!decrypted)
{
throw new Saml2ResponseFailedValidationException("Encrypted Assertion(s) could not be decrypted using the configured Service Certificate(s).");

throw new Saml2ResponseFailedValidationException("Encrypted Assertion(s) could not be decrypted using the configured Service Certificate(s)");
}
}

Expand Down

0 comments on commit 6f8966b

Please sign in to comment.