public static string Generate(KeyInfo keyInfo)
        {
            var str = "";

            foreach (var data in keyInfo.X509Data)
            {
                // Make a new list of elements for each X509Data object
                var elements = new List <XmlEement>();
                foreach (var certificate in data.Certificates)
                {
                    elements.Add(new XmlEement(XmlSignatureConstants.Elements.X509Certificate, certificate));
                }
                if (data.IssuerSerial != null)
                {
                    if (!string.IsNullOrEmpty(data.IssuerSerial.IssuerName))
                    {
                        elements.Add(new XmlEement(XmlSignatureConstants.Elements.X509IssuerName, data.IssuerSerial.IssuerName));
                    }

                    if (!string.IsNullOrEmpty(data.IssuerSerial.SerialNumber))
                    {
                        elements.Add(new XmlEement(XmlSignatureConstants.Elements.X509SerialNumber, data.IssuerSerial.SerialNumber));
                    }
                }
                if (!string.IsNullOrEmpty(data.SKI))
                {
                    elements.Add(new XmlEement(XmlSignatureConstants.Elements.X509SKI, data.SKI));
                }

                if (!string.IsNullOrEmpty(data.SubjectName))
                {
                    elements.Add(new XmlEement(XmlSignatureConstants.Elements.X509SubjectName, data.SubjectName));
                }

                str += XmlEement.Generate(new XmlEement(XmlSignatureConstants.Elements.X509Data, elements));
            }

            return(string.Format(KeyInfoTemplate, XmlSignatureConstants.Namespace, str));
        }
 public static string KeyInfoXml(string @namespace, XmlEement x509Data)
 {
     return(string.Format(KeyInfoTemplate, @namespace, XmlEement.Generate(x509Data)));
 }