Type Default Value Read Only Description
[C#]
SigningDelegate

[Visual Basic]
SigningDelegate
null No A delegate called to perform custom signing of the PDF.

 

   

Notes
 

A delegate called to perform a custom signing of the PDF content digest and signed attributes.

The definition of the SigningDelegate delegate is as follows.

 

delegate byte[] SigningDelegate(byte[] data);;

The function is provided an ASN.1 encoded byte array containing the digest of the PDF content.

It should return a signed encoded CMS - an ASN.1 encoded object containing the signature.

 

   

Example
 

The following example shows how an external delegate might be used.

 

using (Doc doc = new Doc()) {   doc.Read(Server.MapPath("mypics/pic.jpg"));   Signature sig = (Signature)doc.Form.Fields["Signature1"];   sig.CustomSigner = ExternalSigner;   sig.Reason = "Test External Signing";   // Just use public certificate from file - i.e. do not obtain from registry   X509Certificate2 cert = new X509Certificate2(Server.MapPath("GlobalSign.cer"));   sig.Sign(cert, true, new Oid(CryptoConfig.MapNameToOID("SHA512")), X509IncludeOption.EndCertOnly);   doc.Save(Server.MapPath("SignedDoc.pdf")); }

The code above uses the following External Signer.

 

byte[] ExternalSigner(byte[] data) {   string serial = "10 20 30 10 40 10 40 50 60 10 20 30"; // needs value   SecureString password = new SecureString(); // needs value   X509Certificate2 cert = null;   X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);   try {     store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly | OpenFlags.MaxAllowed);     cert = store.Certificates.Find(X509FindType.FindBySerialNumber, serial, false)[0];   }   finally {     store.Close();   }   if (cert.PrivateKey is RSACryptoServiceProvider == false)     throw new Exception("Unsupported key type.");   RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)cert.PrivateKey;   CspParameters cspParams = new CspParameters(1, rsa.CspKeyContainerInfo.ProviderName,     rsa.CspKeyContainerInfo.UniqueKeyContainerName) {     KeyPassword = password,     Flags = CspProviderFlags.NoPrompt   };   RSACryptoServiceProvider service = new RSACryptoServiceProvider(cspParams);   return service.SignData(data, "2.16.840.1.101.3.4.2.3"); }