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:
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:
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:
- Open PFX file and pass PFX password to DigitalSignature object.
- Add created signature to the presentation object.
#[TODO:Exception] RuntimeError: Proxy error(FileNotFoundException): Could not load file or assembly 'System.Security.Cryptography.Xml, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. File was not found.
import aspose.slides as slides
with slides.Presentation() as pres:
# Create DigitalSignature object with PFX file and PFX password
signature = slides.DigitalSignature(path + "testsignature1.pfx", "testpass1")
# Comment new digital signature
signature.comments = "Aspose.Slides digital signing test."
# Add digital signature to presentation
pres.digital_signatures.add(signature)
# save presentation
pres.save("SomePresentationSigned.pptx", slides.export.SaveFormat.PPTX)
Now its possible to check if the presentation was digitally signed and has not been modified:
# Open presentation
with slides.Presentation("SomePresentationSigned.pptx") as pres:
if len(pres.digital_signatures) > 0:
allSignaturesAreValid = True
print("Signatures used to sign the presentation: ")
# Check if all digital signatures are valid
for signature in pres.digital_signatures :
print(signature.certificate.subject_name.name + ", "
+ signature.sign_time.strftime("yyyy-MM-dd HH:mm") + " -- " + "VALID" if signature.is_valid else "INVALID")
allSignaturesAreValid = allSignaturesAreValid and signature.is_valid
if allSignaturesAreValid:
print("Presentation is genuine, all signatures are valid.")
else:
print("Presentation has been modified since signing.")