The following example shows how to prefer CRLs and include a
timestamp when adding long-term validation for a PAdES_B_LT
signature.
[C#]
using(Doc doc = new Doc()) {
doc.Read("BlankSignature.pdf");
Signature sig =
(Signature)doc.Form.Fields["Signature1"];
sig.Reason = "Final Version";
sig.Location = "New York";
sig.CompliancePades =
Signature.PadesLevel.PAdES_B_LT;
sig.DocumentSecurityStorePolicy =
Signature.RevocationCheckingPolicy.PreferCRL; // Prefer CRLs -
could make the file much larger.
sig.TimestampServiceUrl = new
Uri("http://timestamp.digicert.com"); // Setting a Timestamp URI
will add a timestamp to the VRI dictionary.
X509Certificate2 cert = new
X509Certificate2("certificate.p12", "1234",
X509KeyStorageFlags.Exportable);
sig.Sign(cert, null, new
Oid(CryptoConfig.MapNameToOID("SHA256")));
doc.Save("SignedDoc.pdf");
}
[Visual Basic]
Dim doc As Doc = New Doc()
doc.Read("BlankSignature.pdf")
Dim sig As Signature = CType(doc.Form.Fields("Signature1"),
Signature)
sig.Reason = "Final Version"
sig.Location = "New York"
sig.CompliancePades = Signature.PadesLevel.PAdES_B_LT
sig.DocumentSecurityStorePolicy =
Signature.RevocationCheckingPolicy.PreferCRL ' Prefer CRLs - could
make the file much larger.
sig.TimestampServiceUrl = New Uri("http://timestamp.digicert.com")
' Setting a Timestamp URI will add a timestamp to the VRI
dictionary.
Dim cert As X509Certificate2 = New
X509Certificate2("certificate.p12", "1234",
X509KeyStorageFlags.Exportable)
sig.Sign(cert, Nothing, New
Oid(CryptoConfig.MapNameToOID("SHA256")))
doc.Save("SignedDoc.pdf")
See also:
FormOperation.AddLongTermValidation.
|
|
|