Skip to content

Instantly share code, notes, and snippets.

@SumindaD
Last active January 5, 2020 06:56
Show Gist options
  • Save SumindaD/90739e03fe3a7023a3a996eb4d3c94cf to your computer and use it in GitHub Desktop.
Save SumindaD/90739e03fe3a7023a3a996eb4d3c94cf to your computer and use it in GitHub Desktop.
/// <summary>
/// Sign the image data with the given certificate and write to the xmlFilePath
/// </summary>
/// <param name="imageBuffer">Image data to sign</param>
/// <param name="certificateBuffer">Private key certificate byte[]</param>
/// <param name="certPassword">Private key certificate Password</param>
/// <param name="xmlFilePath">The path to save the signed XML</param>
public static void SignImage(byte[] imageBuffer, byte[] certificateBuffer,string certPassword, string xmlFilePath)
{
var certificate = new X509Certificate2(certificateBuffer, certPassword);
var xmlDocumentBuffer = SerializeImageToXML(imageBuffer);
SignXMLDocument(xmlDocumentBuffer, certificate, xmlFilePath);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment