Verify signature on SAML assertion

This example code verifies SAML response using UltimateSAML. It helps verify nested SAML assertion signature inside a response.

XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(samlResponseXmlToVerify);

XmlDocument xmlDocumentMetadata = new XmlDocument();
xmlDocumentMetadata.Load(samlMetadataXmlToExtractCertData);

// Load the SAML response from the XML document.
Response samlResponse = new Response(xmlDocument.DocumentElement);

// Is it signed?
if (samlResponse.IsSigned())
{
    // Validate the SAML response with the certificate.
    if (!samlResponse.Validate(xmlDocumentMetadata.DocumentElement))
    {
        throw new ApplicationException("SAML response signature is not valid.");
    }
} ;

Check the following link for more detailed online example

http://www.componentpro.com/doc/saml/ComponentPro.Saml.SignableSamlObject.Validate().htm Costa Rica domain names earth map website tech information

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>