Digital Signature in PowerPoint

Digital certificate is used to create a password protected powerpoint presentation, marked as created by a particular organization or person. Digital certificate can be obtained by contacting an authorized organization - a certificate authority. After installing digital certificate into the system, it can be used to add a digital signature to the presentation via File -> Info -> Protect Presentation:

todo:image_alt_text

Presentation may contain more than one digital signatures. After the digital signature is added to the presentation, a special message will appear in the PowerPoint:

todo:image_alt_text

To sign presentation or check the authenticity of presentation signatures, Aspose.Slides API provides IDigitalSignature interface, IDigitalSignatureCollection interface and IPresentation.DigitalSignatures property. Currently, digital signatures are supported for PPTX format only.

Add Digital Signature from PFX Certificate

The code sample below demonstrates how to add digital signature from a PFX certificate:

  1. Open PFX file and pass PFX password to DigitalSignature object.
  2. Add created signature to the presentation object.
using (Presentation pres = new Presentation())
{
    // Create DigitalSignature object with PFX file and PFX password 
    DigitalSignature signature = new DigitalSignature("testsignature1.pfx", @"testpass1");

    // Comment new digital signature
    signature.Comments = "Aspose.Slides digital signing test.";

    // Add digital signature to presentation
    pres.DigitalSignatures.Add(signature);

    // Save presentation
    pres.Save("SomePresentationSigned.pptx", SaveFormat.Pptx);
}

Now its possible to check if the presentation was digitally signed and has not been modified:

// Open presentation
using (Presentation pres = new Presentation("SomePresentationSigned.pptx"))
{
    if (pres.DigitalSignatures.Count > 0)
    {
        bool allSignaturesAreValid = true;

        Console.WriteLine("Signatures used to sign the presentation: ");

        // Check if all digital signatures are valid
        foreach (DigitalSignature signature in pres.DigitalSignatures)
        {
            Console.WriteLine(signature.Certificate.SubjectName.Name + ", "
                    + signature.SignTime.ToString("yyyy-MM-dd HH:mm") + " -- " + (signature.IsValid ? "VALID" : "INVALID"));
            allSignaturesAreValid &= signature.IsValid;
        }

        if (allSignaturesAreValid)
            Console.WriteLine("Presentation is genuine, all signatures are valid.");
        else
            Console.WriteLine("Presentation has been modified since signing.");
    }
}