Add project
Basic formatting applied. Unnecessary comments have been removed. Suspicious code is covered by TODO.
This commit is contained in:
28
Hcs.Client/GostXades/Helpers/KeyInfoHelper.cs
Normal file
28
Hcs.Client/GostXades/Helpers/KeyInfoHelper.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Security.Cryptography.Xml;
|
||||
using System.Xml;
|
||||
|
||||
namespace Hcs.GostXades.Helpers
|
||||
{
|
||||
public static class KeyInfoHelper
|
||||
{
|
||||
public static KeyInfo Create(X509Certificate2 certificate)
|
||||
{
|
||||
var xmlDocument = new XmlDocument();
|
||||
|
||||
var x509DataElement = xmlDocument.CreateElement("ds", "X509Data", KeyInfoNamespace);
|
||||
var x509CertificateElement = xmlDocument.CreateElement("ds", "X509Certificate", KeyInfoNamespace);
|
||||
x509CertificateElement.InnerText = Convert.ToBase64String(certificate.GetRawCertData());
|
||||
|
||||
x509DataElement.AppendChild(x509CertificateElement);
|
||||
|
||||
var keyInfo = new KeyInfo();
|
||||
keyInfo.AddClause(new KeyInfoNode(x509DataElement));
|
||||
|
||||
return keyInfo;
|
||||
}
|
||||
|
||||
private const string KeyInfoNamespace = "http://www.w3.org/2000/09/xmldsig#";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user