Generating Federation Metadata XML from the LocalServiceProviderConfiguration

We are exposing our SP FederationMetadata.xml using an endpoint in our site. Currently we have a XML file that we serve for from this endpoint. I am trying to generate the FederationMetadata.xml programatically using the ComponentSpace.Saml2 library.
For this i am using ConfigurationToMetadata().Export method by providing the SamlConfiguration and a list of signing and encryption certificates. But there are some differences between the programatically generated Metadata XML and the current metadata XML file (which is in a XML file mentioned above)

1. Our old Metadata file contains the Following Organization and ContactPerson elements.

But the newly generated Metadata filed does not contain these and there is no way to set them in the But the newly generated Metadata filed does not contain these and there is no way to set them in the LocalServiceProviderConfiguration
The method to generate the LocalServiceProviderConfiguration is below

private LocalServiceProviderConfiguration GetLocalServiceProviderConfiguration()
var serviceProviderUrl = _appSettings.ServiceProvider;
return new LocalServiceProviderConfiguration
Name = serviceProviderUrl,
Description = “**“,
AssertionConsumerServiceUrl = $”{serviceProviderUrl}/Saml/AssertionConsumerService",
SingleLogoutServiceUrl = $“{serviceProviderUrl}/Saml/SLOServiceSP”,
LocalCertificates = new List
new Certificate
FileName = "
Password = “*******”

2. Also our old Metadata XML file has WantAssertionsSigned=“true” set in the SPSSODescriptor element. But in the newly generated XML it is not set and there is no way of setting this in the LocalServiceProviderConfiguration.
3. Our old Metadata XML file contains 3 binding for the AssertionConsumerService URL element. They are HTTP-POST, HTTP-Artifact and HTTP-Redirect, in the generated XML only the HTTP-POST link is added.

I want to make the newly generated Federation Metadata XML matches exactly to the old XML file. How can i set the missing XML elements and attributes on the LocalServiceProviderConfiguration?

This information can’t be included in the local SAML configuration.
Instead, call ComponentSpace.SAML2.Configuration.MetadataExporter.Export.
This returns an EntityDescriptor object.
Update the EntityDescriptor to include the additional information, serialize it to XML and save it.
The assertion consumer service binding can be HTTP-Post or HTTP-Artifact. You can’t use HTTP-Redirect as this isn’t supported by the SAML specification.

It worked. Thank you very much :slight_smile:

You’re welcome. :slight_smile: