Platforms
Frameworks
Languages
Platform Specifics
File format support
The Apryse custom signing API is a set of APIs related to cryptographic digital signatures which allows users to customize the process of signing documents. Among other things, this includes the capability to allow for easy integration of PDF-specific signing-related operations with access to Hardware Security Module (HSM) tokens/devices, access to cloud keystores, access to system keystores, etc. The intent behind this API is to remove the old, tricky, and complicated requirement for users with specific needs to create custom SignatureHandler functor objects.
What follows is a simple code guide to the use of the custom signing API. Please note: any of the steps can be replaced with your own code that provides some custom functionality.
1PDFDoc doc = new PDFDoc(in_docpath);
2
3Page page1 = doc.GetPage(1);
4
5// Create a digital signature field and associated widget.
6DigitalSignatureField digsig_field = doc.CreateDigitalSignatureField(in_sig_field_name);
7SignatureWidget widgetAnnot = SignatureWidget.Create(doc, new Rect(143, 287, 219, 306), digsig_field);
8page1.AnnotPushBack(widgetAnnot);
9
10// Create a digital signature dictionary inside the digital signature field, in preparation for signing.
11digsig_field.CreateSigDictForCustomSigning("Adobe.PPKLite",
12 in_PAdES_signing_mode? DigitalSignatureField.SubFilterType.e_ETSI_CAdES_detached : DigitalSignatureField.SubFilterType.e_adbe_pkcs7_detached,
13 7500); // For security reasons, set the contents size to a value greater than but as close as possible to the size you expect your final signature to be, in bytes.
14// ... or, if you want to apply a certification signature, use CreateSigDictForCustomCertification instead.
15
16// (OPTIONAL) Set the signing time in the signature dictionary, if no secure embedded timestamping support is available from your signing provider.
17Date current_date = new Date();
18current_date.SetCurrentTime();
19digsig_field.SetSigDictTimeOfSigning(current_date);
20
21// Save the document incrementally to avoid invalidating any previous signatures.
22doc.Save(in_outpath, SDFDoc.SaveOptions.e_incremental);
23
24// Digest the relevant bytes of the document in accordance with ByteRanges surrounding the signature.
25byte[] pdf_digest = digsig_field.CalculateDigest(DigestAlgorithm.Type.e_sha256);
26
27X509Certificate signer_cert = new X509Certificate(in_cert_path);
28
29/* Optionally, you can add a custom signed attribute at this point, such as one of the PAdES ESS attributes.
30The function we provide takes care of generating the correct PAdES ESS attribute depending on your digest algorithm. */
31byte[] pades_versioned_ess_signing_cert_attribute = digsig_field.GenerateESSSigningCertPAdESAttribute(
32 signer_cert, DigestAlgorithm.Type.e_sha256);
33
34// Generate the signedAttrs component of CMS, passing any optional custom signedAttrs (e.g. PAdES ESS). The signedAttrs are certain attributes that become protected by their inclusion in the signature.
35byte[] signedAttrs = DigitalSignatureField.GenerateCMSSignedAttributes(pdf_digest,
36 pades_versioned_ess_signing_cert_attribute);
37
38// Calculate the digest of the signedAttrs (i.e. not the PDF digest, this time).
39byte[] signedAttrs_digest = DigestAlgorithm.CalculateDigest(DigestAlgorithm.Type.e_sha256, signedAttrs);
1PDFDoc doc(in_docpath);
2
3Page page1 = doc.GetPage(1);
4
5// Create a digital signature field and associated widget.
6DigitalSignatureField digsig_field = doc.CreateDigitalSignatureField(in_sig_field_name);
7Annots::SignatureWidget widgetAnnot = Annots::SignatureWidget::Create(doc, Rect(143, 287, 219, 306), digsig_field);
8page1.AnnotPushBack(widgetAnnot);
9
10// Create a digital signature dictionary inside the digital signature field, in preparation for signing.
11digsig_field.CreateSigDictForCustomSigning("Adobe.PPKLite",
12 in_PAdES_signing_mode ? DigitalSignatureField::SubFilterType::e_ETSI_CAdES_detached : DigitalSignatureField::SubFilterType::e_adbe_pkcs7_detached,
13 7500); // For security reasons, set the contents size to a value greater than but as close as possible to the size you expect your final signature to be, in bytes.
14// ... or, if you want to apply certification signature, use CreateSigDictForCustomCertification instead.
15
16// (OPTIONAL) Set the signing time in the signature dictionary, if no secure embedded timestamping support is available from your signing provider.
17Date current_date;
18current_date.SetCurrentTime();
19digsig_field.SetSigDictTimeOfSigning(current_date);
20
21// Save the document incrementally to avoid invalidating any previous signatures.
22doc.Save(in_outpath, SDFDoc::e_incremental, 0);
23
24// Digest the relevant bytes of the document in accordance with ByteRanges surrounding the signature.
25vector<UChar> pdf_digest(digsig_field.CalculateDigest(Crypto::DigestAlgorithm::e_SHA256));
26
27Crypto::X509Certificate signer_cert(in_cert_path);
28
29/* Optionally, you can add a custom signed attribute at this point, such as one of the PAdES ESS attributes.
30The function we provide takes care of generating the correct PAdES ESS attribute depending on your digest algorithm. */
31vector<UChar> pades_versioned_ess_signing_cert_attribute(DigitalSignatureField::GenerateESSSigningCertPAdESAttribute(
32 signer_cert, Crypto::DigestAlgorithm::e_SHA256));
33
34// Generate the signedAttrs component of CMS, passing any optional custom signedAttrs (e.g. PAdES ESS). The signedAttrs are certain attributes that become protected by their inclusion in the signature.
35vector<UChar> signedAttrs(DigitalSignatureField::GenerateCMSSignedAttributes(pdf_digest.data(), pdf_digest.size(),
36 pades_versioned_ess_signing_cert_attribute.data(), pades_versioned_ess_signing_cert_attribute.size()));
37
38// Calculate the digest of the signedAttrs (i.e. not the PDF digest, this time).
39vector<UChar> signedAttrs_digest(Crypto::DigestAlgorithm::CalculateDigest(Crypto::DigestAlgorithm::e_SHA256, signedAttrs.data(), signedAttrs.size()));
1doc := NewPDFDoc(in_docpath)
2
3page1 := doc.GetPage(1)
4
5// Create a digital signature field and associated widget.
6digsig_field := doc.CreateDigitalSignatureField(in_sig_field_name)
7widgetAnnot := SignatureWidgetCreate(doc, NewRect(143.0, 287.0, 219.0, 306.0), digsig_field)
8page1.AnnotPushBack(widgetAnnot)
9
10signing_mode := DigitalSignatureFieldE_adbe_pkcs7_detached
11if in_PAdES_signing_mode {
12signing_mode = DigitalSignatureFieldE_ETSI_CAdES_detached
13}
14// Create a digital signature dictionary inside the digital signature field, in preparation for signing.
15digsig_field.CreateSigDictForCustomSigning("Adobe.PPKLite",
16 &signing_mode,
17 7500) // For security reasons, set the contents size to a value greater than but as close as possible to the size you expect your final signature to be, in bytes.
18// ... or, if you want to apply a certification signature, use CreateSigDictForCustomCertification instead.
19
20// (OPTIONAL) Set the signing time in the signature dictionary, if no secure embedded timestamping support is available from your signing provider.
21current_date := NewDate()
22current_date.SetCurrentTime()
23digsig_field.SetSigDictTimeOfSigning(current_date)
24
25// Save the document incrementally to avoid invalidating any previous signatures.
26doc.Save(in_outpath, uint(SDFDocE_incremental))
27
28// Digest the relevant bytes of the document in accordance with ByteRanges surrounding the signature.
29pdf_digest := digsig_field.CalculateDigest(DigestAlgorithmE_SHA256)
30
31signer_cert := NewX509Certificate(in_cert_path)
32
33/* Optionally, you can add a custom signed attribute at this point, such as one of the PAdES ESS attributes.
34The function we provide takes care of generating the correct PAdES ESS attribute depending on your digest algorithm. */
35pades_versioned_ess_signing_cert_attribute := DigitalSignatureFieldGenerateESSSigningCertPAdESAttribute(signer_cert, DigestAlgorithmE_SHA256)
36
37// Generate the signedAttrs component of CMS, passing any optional custom signedAttrs (e.g. PAdES ESS).
38// The signedAttrs are certain attributes that become protected by their inclusion in the signature.
39signedAttrs := DigitalSignatureFieldGenerateCMSSignedAttributes(pdf_digest, pades_versioned_ess_signing_cert_attribute)
40
41// Calculate the digest of the signedAttrs (i.e. not the PDF digest, this time).
42signedAttrs_digest := DigestAlgorithmCalculateDigest(DigestAlgorithmE_SHA256, signedAttrs)
1PDFDoc doc = new PDFDoc(in_docpath);
2
3Page page1 = doc.getPage(1);
4
5// Create a digital signature field and associated widget.
6DigitalSignatureField digsig_field = doc.createDigitalSignatureField(in_sig_field_name);
7SignatureWidget widgetAnnot = SignatureWidget.create(doc, new Rect(143, 287, 219, 306), digsig_field);
8page1.annotPushBack(widgetAnnot);
9
10// Create a digital signature dictionary inside the digital signature field, in preparation for signing.
11digsig_field.createSigDictForCustomSigning("Adobe.PPKLite",
12 in_PAdES_signing_mode? DigitalSignatureField.SubFilterType.e_ETSI_CAdES_detached : DigitalSignatureField.SubFilterType.e_adbe_pkcs7_detached,
13 7500); // For security reasons, set the contents size to a value greater than but as close as possible to the size you expect your final signature to be, in bytes.
14// ... or, if you want to apply a certification signature, use createSigDictForCustomCertification instead.
15
16// (OPTIONAL) Set the signing time in the signature dictionary, if no secure embedded timestamping support is available from your signing provider.
17Date current_date = new Date();
18current_date.setCurrentTime();
19digsig_field.setSigDictTimeOfSigning(current_date);
20
21// Save the document incrementally to avoid invalidating any previous signatures.
22doc.save(in_outpath, SDFDoc.SaveMode.INCREMENTAL, null);
23
24// Digest the relevant bytes of the document in accordance with ByteRanges surrounding the signature.
25byte[] pdf_digest = digsig_field.calculateDigest(DigestAlgorithm.e_sha256);
26
27X509Certificate signer_cert = new X509Certificate(in_cert_path);
28
29/* Optionally, you can add a custom signed attribute at this point, such as one of the PAdES ESS attributes.
30The function we provide takes care of generating the correct PAdES ESS attribute depending on your digest algorithm. */
31byte[] pades_versioned_ess_signing_cert_attribute = digsig_field.generateESSSigningCertPAdESAttribute(
32 signer_cert, DigestAlgorithm.e_sha256);
33
34// Generate the signedAttrs component of CMS, passing any optional custom signedAttrs (e.g. PAdES ESS). The signedAttrs are certain attributes that become protected by their inclusion in the signature.
35byte[] signedAttrs = DigitalSignatureField.generateCMSSignedAttributes(pdf_digest,
36 pades_versioned_ess_signing_cert_attribute);
37
38// Calculate the digest of the signedAttrs (i.e. not the PDF digest, this time).
39byte[] signedAttrs_digest = DigestAlgorithm.calculateDigest(DigestAlgorithm.e_sha256, signedAttrs);
1const doc = await PDFNet.PDFDoc.createFromFilePath(in_docpath);
2
3const page1 = await doc.getPage(1);
4
5// Create a digital signature field and associated widget.
6const digsig_field = await doc.createDigitalSignatureField(in_sig_field_name);
7const widgetAnnot = await PDFNet.SignatureWidget.createWithDigitalSignatureField(doc, new PDFNet.Rect(143, 287, 219, 306), digsig_field);
8await page1.annotPushBack(widgetAnnot);
9
10// Create a digital signature dictionary inside the digital signature field, in preparation for signing.
11await digsig_field.createSigDictForCustomSigning("Adobe.PPKLite",
12 in_PAdES_signing_mode? PDFNet.DigitalSignatureField.SubFilterType.e_ETSI_CAdES_detached : PDFNet.DigitalSignatureField.SubFilterType.e_adbe_pkcs7_detached,
13 7500); // For security reasons, set the contents size to a value greater than but as close as possible to the size you expect your final signature to be, in bytes.
14// ... or, if you want to apply a certification signature, use createSigDictForCustomCertification instead.
15
16// (OPTIONAL) Set the signing time in the signature dictionary, if no secure embedded timestamping support is available from your signing provider.
17const current_date = new PDFNet.Date();
18await current_date.setCurrentTime();
19await digsig_field.setSigDictTimeOfSigning(current_date);
20
21await doc.save(in_outpath, PDFNet.SDFDoc.SaveOptions.e_incremental);
22
23// Digest the relevant bytes of the document in accordance with ByteRanges surrounding the signature.
24const pdf_digest = await digsig_field.calculateDigest(PDFNet.DigestAlgorithm.Type.e_SHA256);
25
26const signer_cert = await PDFNet.X509Certificate.createFromFile(in_cert_path);
27
28/* Optionally, you can add a custom signed attribute at this point, such as one of the PAdES ESS attributes.
29The function we provide takes care of generating the correct PAdES ESS attribute depending on your digest algorithm. */
30const pades_versioned_ess_signing_cert_attribute = await PDFNet.DigitalSignatureField.generateESSSigningCertPAdESAttribute(signer_cert, PDFNet.DigestAlgorithm.Type.e_SHA256);
31
32// Generate the signedAttrs component of CMS, passing any optional custom signedAttrs (e.g. PAdES ESS). The signedAttrs are certain attributes that become protected by their inclusion in the signature.
33const signedAttrs = await PDFNet.DigitalSignatureField.generateCMSSignedAttributes(pdf_digest,
34 pades_versioned_ess_signing_cert_attribute);
35
36// Calculate the digest of the signedAttrs (i.e. not the PDF digest, this time).
37const signedAttrs_digest = await PDFNet.DigestAlgorithm.calculateDigest(PDFNet.DigestAlgorithm.Type.e_SHA256, signedAttrs);
1PTPDFDoc* doc = [[PTPDFDoc alloc] initWithFilepath: in_docpath];
2
3PTPage* page1 = [doc GetPage: 1];
4
5// Create a digital signature field and associated widget.
6PTDigitalSignatureField* digsig_field = [doc CreateDigitalSignatureField: in_sig_field_name];
7PTSignatureWidget* widgetAnnot = [PTSignatureWidget CreateWithDigitalSignatureField: doc pos: [[PTPDFRect alloc] initWithX1: 143 y1: 287 x2: 219 y2: 306] field: digsig_field];
8[page1 AnnotPushBack: widgetAnnot];
9
10// Create a digital signature dictionary inside the digital signature field, in preparation for signing.
11// For security reasons, set the contents size to a value greater than but as close as possible to the size you expect your final signature to be, in bytes.
12// ... or, if you want to apply a certification signature, use createSigDictForCustomCertification instead.
13[digsig_field CreateSigDictForCustomSigning: @"Adobe.PPKLite" in_subfilter_type: e_ptadbe_pkcs7_detached in_contents_size_to_reserve: 7500];
14
15// (OPTIONAL) Set the signing time in the signature dictionary, if no secure embedded timestamping support is available from your signing provider.
16PTDate* current_date = [[PTDate alloc] init];
17[current_date SetCurrentTime];
18[digsig_field SetSigDictTimeOfSigning: current_date];
19
20// Save the document incrementally to avoid invalidating any previous signatures.
21[doc SaveToFile: in_outpath flags: e_ptincremental];
22
23// Digest the relevant bytes of the document in accordance with ByteRanges surrounding the signature.
24NSData* pdf_digest = [digsig_field CalculateDigest: e_ptsha256];
25
26PTX509Certificate* signer_cert = [[PTX509Certificate alloc] initWithIn_certificate_path: in_cert_path];
27
28// Optionally, you can add a custom signed attribute at this point, such as one of the PAdES ESS attributes.
29// The function we provide takes care of generating the correct PAdES ESS attribute depending on your digest algorithm.
30NSData* pades_versioned_ess_signing_cert_attribute = [PTDigitalSignatureField GenerateESSSigningCertPAdESAttribute: signer_cert in_digest_algorithm_type: e_ptsha256];
31
32// Generate the signedAttrs component of CMS, passing any optional custom signedAttrs (e.g. PAdES ESS). The signedAttrs are certain attributes that become protected by their inclusion in the signature.
33NSData* signedAttrs = [PTDigitalSignatureField GenerateCMSSignedAttributes: pdf_digest in_custom_signedattributes_buf: pades_versioned_ess_signing_cert_attribute];
34
35// Calculate the digest of the signedAttrs (i.e. not the PDF digest, this time).
36NSData* signedAttrs_digest = [PTDigestAlgorithm CalculateDigest: e_ptsha256 in_message_buf: signedAttrs];
1$doc = new PDFDoc($in_docpath);
2$page1 = $doc->GetPage(1);
3
4// Create a digital signature field and associated widget.
5$digsig_field = $doc->CreateDigitalSignatureField($in_sig_field_name);
6$widgetAnnot = SignatureWidget::Create($doc, new Rect(143.0, 287.0, 219.0, 306.0), $digsig_field);
7$page1->AnnotPushBack($widgetAnnot);
8
9// Create a digital signature dictionary inside the digital signature field, in preparation for signing.
10$digsig_field->CreateSigDictForCustomSigning("Adobe.PPKLite",
11 $in_PAdES_signing_mode? DigitalSignatureField::e_ETSI_CAdES_detached : DigitalSignatureField::e_adbe_pkcs7_detached,
12 7500); // For security reasons, set the contents size to a value greater than but as close as possible to the size you expect your final signature to be, in bytes.
13// ... or, if you want to apply a certification signature, use CreateSigDictForCustomCertification instead.
14
15// (OPTIONAL) Set the signing time in the signature dictionary, if no secure embedded timestamping support is available from your signing provider.
16$current_date = new Date();
17$current_date->SetCurrentTime();
18$digsig_field->SetSigDictTimeOfSigning($current_date);
19
20// Save the document incrementally to avoid invalidating any previous signatures.
21$doc->Save($in_outpath, SDFDoc::e_incremental);
22
23// Digest the relevant bytes of the document in accordance with ByteRanges surrounding the signature.
24$pdf_digest = $digsig_field->CalculateDigest(DigestAlgorithm::e_SHA256);
25
26$signer_cert = new X509Certificate($in_cert_path);
27
28/* Optionally, you can add a custom signed attribute at this point, such as one of the PAdES ESS attributes.
29The function we provide takes care of generating the correct PAdES ESS attribute depending on your digest algorithm. */
30$pades_versioned_ess_signing_cert_attribute = DigitalSignatureField::GenerateESSSigningCertPAdESAttribute(
31 $signer_cert, DigestAlgorithm::e_SHA256);
32
33// Generate the signedAttrs component of CMS, passing any optional custom signedAttrs (e.g. PAdES ESS). The signedAttrs are certain attributes that become protected by their inclusion in the signature.
34$signedAttrs = DigitalSignatureField::GenerateCMSSignedAttributes($pdf_digest,
35 $pades_versioned_ess_signing_cert_attribute);
36
37// Calculate the digest of the signedAttrs (i.e. not the PDF digest, this time).
38$signedAttrs_digest = DigestAlgorithm::CalculateDigest(DigestAlgorithm::e_SHA256, $signedAttrs);
1doc = PDFDoc(in_docpath)
2
3page1 = doc.GetPage(1)
4
5# Create a digital signature field and associated widget.
6digsig_field = doc.CreateDigitalSignatureField(in_sig_field_name)
7widgetAnnot = SignatureWidget.Create(doc, Rect(143, 287, 219, 306), digsig_field)
8page1.AnnotPushBack(widgetAnnot)
9
10# Create a digital signature dictionary inside the digital signature field, in preparation for signing.
11digsig_field.CreateSigDictForCustomSigning('Adobe.PPKLite',
12 DigitalSignatureField.e_ETSI_CAdES_detached if in_PAdES_signing_mode else DigitalSignatureField.e_adbe_pkcs7_detached,
13 7500) # For security reasons, set the contents size to a value greater than but as close as possible to the size you expect your final signature to be, in bytes.
14# ... or, if you want to apply a certification signature, use createSigDictForCustomCertification instead.
15
16# (OPTIONAL) Set the signing time in the signature dictionary, if no secure embedded timestamping support is available from your signing provider.
17current_date = Date()
18current_date.SetCurrentTime()
19digsig_field.SetSigDictTimeOfSigning(current_date)
20
21# Save the document incrementally to avoid invalidating any previous signatures.
22doc.Save(in_outpath, SDFDoc.e_incremental)
23
24# Digest the relevant bytes of the document in accordance with ByteRanges surrounding the signature.
25pdf_digest = digsig_field.CalculateDigest(DigestAlgorithm.e_SHA256)
26
27signer_cert = X509Certificate(in_cert_path)
28
29# Optionally, you can add a custom signed attribute at this point, such as one of the PAdES ESS attributes.
30# The function we provide takes care of generating the correct PAdES ESS attribute depending on your digest algorithm.
31pades_versioned_ess_signing_cert_attribute = DigitalSignatureField.GenerateESSSigningCertPAdESAttribute(signer_cert, DigestAlgorithm.e_SHA256)
32
33# Generate the signedAttrs component of CMS, passing any optional custom signedAttrs (e.g. PAdES ESS). The signedAttrs are certain attributes that become protected by their inclusion in the signature.
34signedAttrs = DigitalSignatureField.GenerateCMSSignedAttributes(pdf_digest, pades_versioned_ess_signing_cert_attribute)
35
36# Calculate the digest of the signedAttrs (i.e. not the PDF digest, this time).
37signedAttrs_digest = DigestAlgorithm.CalculateDigest(DigestAlgorithm.e_SHA256, signedAttrs)
1doc = PDFDoc.new(in_docpath);
2
3page1 = doc.GetPage(1);
4
5# Create a digital signature field and associated widget.
6digsig_field = doc.CreateDigitalSignatureField(in_sig_field_name);
7widgetAnnot = SignatureWidget.Create(doc, Rect.new(143, 287, 219, 306), digsig_field);
8page1.AnnotPushBack(widgetAnnot);
9
10# Create a digital signature dictionary inside the digital signature field, in preparation for signing.
11digsig_field.CreateSigDictForCustomSigning("Adobe.PPKLite",
12 in_PAdES_signing_mode ? DigitalSignatureField::E_ETSI_CAdES_detached : DigitalSignatureField::E_adbe_pkcs7_detached,
13 7500); # For security reasons, set the contents size to a value greater than but as close as possible to the size you expect your final signature to be, in bytes.
14 # ... or, if you want to apply a certification signature, use CreateSigDictForCustomCertification instead.
15
16# (OPTIONAL) Set the signing time in the signature dictionary, if no secure embedded timestamping support is available from your signing provider.
17current_date = Date.new();
18current_date.SetCurrentTime();
19digsig_field.SetSigDictTimeOfSigning(current_date);
20
21# Save the document incrementally to avoid invalidating any previous signatures.
22doc.Save(in_outpath, SDFDoc::E_incremental);
23
24# Digest the relevant bytes of the document in accordance with ByteRanges surrounding the signature.
25pdf_digest = digsig_field.CalculateDigest(DigestAlgorithm::E_SHA256);
26
27signer_cert = X509Certificate.new(in_cert_path);
28
29# Optionally, you can add a custom signed attribute at this point, such as one of the PAdES ESS attributes.
30# The function we provide takes care of generating the correct PAdES ESS attribute depending on your digest algorithm.
31pades_versioned_ess_signing_cert_attribute = DigitalSignatureField.GenerateESSSigningCertPAdESAttribute(signer_cert, DigestAlgorithm::E_SHA256);
32
33# Generate the signedAttrs component of CMS, passing any optional custom signedAttrs (e.g. PAdES ESS). The signedAttrs are certain attributes that become protected by their inclusion in the signature.
34signedAttrs = DigitalSignatureField.GenerateCMSSignedAttributes(pdf_digest, pades_versioned_ess_signing_cert_attribute);
35
36# Calculate the digest of the signedAttrs (i.e. not the PDF digest, this time).
37signedAttrs_digest = DigestAlgorithm.CalculateDigest(DigestAlgorithm::E_SHA256, signedAttrs);
At this point, use your signing provider (e.g. HSM device, cloud keystore) to sign the digest of signedAttrs. Your input should be the variable signedAttrs_digest. In the following code, we assume the output is in a variable named signature_value.
1// Then, load all your chain certificates into a container of X509Certificate.
2X509Certificate[] chain_certs = {};
3
4// Then, create ObjectIdentifiers for the algorithms you have used.
5ObjectIdentifier digest_algorithm_oid = new ObjectIdentifier(DigestAlgorithm.Type.e_sha256);
6ObjectIdentifier signature_algorithm_oid = new ObjectIdentifier(ObjectIdentifier.Predefined.e_RSA_encryption_PKCS1);
7
8// Then, put the CMS signature components together.
9byte[] cms_signature = DigitalSignatureField.GenerateCMSSignature(
10 signer_cert, chain_certs, digest_algorithm_oid, signature_algorithm_oid,
11 signature_value, signedAttrs);
12
13// Write the signature to the document.
14doc.SaveCustomSignature(cms_signature, digsig_field, in_outpath);
1// Then, load all your chain certificates into a container of X509Certificate.
2vector<Crypto::X509Certificate> chain_certs;
3
4// Then, create ObjectIdentifiers for the algorithms you have used.
5Crypto::ObjectIdentifier digest_algorithm_oid(Crypto::DigestAlgorithm::e_SHA256);
6Crypto::ObjectIdentifier signature_algorithm_oid(Crypto::ObjectIdentifier::e_RSA_encryption_PKCS1);
7
8// Then, put the CMS signature components together.
9vector<UChar> cms_signature(DigitalSignatureField::GenerateCMSSignature(
10 signer_cert, chain_certs.data(), chain_certs.size(), digest_algorithm_oid, signature_algorithm_oid,
11 signature_value.data(), signature_value.size(), signedAttrs.data(), signedAttrs.size()));
12
13// Write the signature to the document.
14doc.SaveCustomSignature(cms_signature.data(), cms_signature.size(), digsig_field, in_outpath);
1// Then, load all your chain certificates into a container of X509Certificate.
2chain_certs := NewVectorX509Certificate()
3
4// Then, create ObjectIdentifiers for the algorithms you have used.
5digest_algorithm_oid := NewObjectIdentifier(DigestAlgorithmE_SHA256)
6signature_algorithm_oid := NewObjectIdentifier(ObjectIdentifierE_RSA_encryption_PKCS1)
7
8// Then, put the CMS signature components together.
9cms_signature := DigitalSignatureFieldGenerateCMSSignature(
10 signer_cert, chain_certs, digest_algorithm_oid, signature_algorithm_oid,
11 signature_value, signedAttrs)
12
13// Write the signature to the document.
14doc.SaveCustomSignature(cms_signature, digsig_field, in_outpath)
1// Then, load all your chain certificates into a container of X509Certificate.
2X509Certificate[] chain_certs = {};
3
4// Then, create ObjectIdentifiers for the algorithms you have used.
5ObjectIdentifier digest_algorithm_oid = new ObjectIdentifier(ObjectIdentifier.Predefined.e_SHA256);
6ObjectIdentifier signature_algorithm_oid = new ObjectIdentifier(ObjectIdentifier.Predefined.e_RSA_encryption_PKCS1);
7
8// Then, put the CMS signature components together.
9byte[] cms_signature = DigitalSignatureField.generateCMSSignature(
10 signer_cert, chain_certs, digest_algorithm_oid, signature_algorithm_oid,
11 signature_value, signedAttrs);
12
13// Write the signature to the document.
14doc.saveCustomSignature(cms_signature, digsig_field, in_outpath);
1// Then, load all your chain certificates into a container of X509Certificate.
2var chain_certs = [];
3
4// Then, create ObjectIdentifiers for the algorithms you have used.
5const digest_algorithm_oid = await PDFNet.ObjectIdentifier.createFromDigestAlgorithm(PDFNet.DigestAlgorithm.Type.e_SHA256);
6const signature_algorithm_oid = await PDFNet.ObjectIdentifier.createFromPredefined(PDFNet.ObjectIdentifier.Predefined.e_RSA_encryption_PKCS1);
7
8// Then, put the CMS signature components together.
9const cms_signature = await PDFNet.DigitalSignatureField.generateCMSSignature(
10 signer_cert, chain_certs, digest_algorithm_oid, signature_algorithm_oid, signature_value,
11 signedAttrs);
12
13// Write the signature to the document.
14await doc.saveCustomSignature(cms_signature, digsig_field, in_outpath);
1// Then, load all your chain certificates into a container of X509Certificate.
2NSArray<PTX509Certificate *> *chain_certs;
3
4// Then, create ObjectIdentifiers for the algorithms you have used.
5PTObjectIdentifier* digest_algorithm_oid = [[PTObjectIdentifier alloc] initWithIn_digest_algorithm_type: e_ptsha256];
6PTObjectIdentifier* signature_algorithm_oid = [[PTObjectIdentifier alloc] initWithIn_oid_enum: e_ptRSA_encryption_PKCS1];
7
8// Then, put the CMS signature components together.
9NSData* cms_signature = [PTDigitalSignatureField GenerateCMSSignature: signer_cert in_chain_certs_list: chain_certs in_digest_algorithm_oid: digest_algorithm_oid in_signature_algorithm_oid: signature_algorithm_oid in_signature_value_buf: signature_value in_signedattributes_buf: signedAttrs];
10
11// Write the signature to the document.
12[doc SaveCustomSignatureToFile: cms_signature in_field: digsig_field in_path: output_path];
1// Then, load all your chain certificates into a container of X509Certificate.
2$chain_certs = new VectorX509Certificate();
3
4// Then, create ObjectIdentifiers for the algorithms you have used.
5$digest_algorithm_oid = new ObjectIdentifier(ObjectIdentifier::e_SHA256);
6$signature_algorithm_oid = new ObjectIdentifier(ObjectIdentifier::e_RSA_encryption_PKCS1);
7
8// Then, put the CMS signature components together.
9$cms_signature = DigitalSignatureField::GenerateCMSSignature(
10 $signer_cert, $chain_certs, $digest_algorithm_oid, $signature_algorithm_oid,
11 $signature_value, $signedAttrs);
12
13// Write the signature to the document.
14$doc->SaveCustomSignature($cms_signature, $digsig_field, $in_outpath);
1# Then, load all your chain certificates into a container of X509Certificate.
2chain_certs = []
3
4# Then, create ObjectIdentifiers for the algorithms you have used.
5digest_algorithm_oid = ObjectIdentifier(ObjectIdentifier.e_SHA256)
6signature_algorithm_oid = ObjectIdentifier(ObjectIdentifier.e_RSA_encryption_PKCS1)
7
8# Then, put the CMS signature components together.
9cms_signature = DigitalSignatureField.GenerateCMSSignature(signer_cert, chain_certs, digest_algorithm_oid, signature_algorithm_oid, signature_value, signedAttrs)
10
11# Write the signature to the document.
12doc.SaveCustomSignature(cms_signature, digsig_field, in_outpath)
1# Then, load all your chain certificates into a container of X509Certificate.
2chain_certs = VectorX509Certificate.new();
3
4# Then, create ObjectIdentifiers for the algorithms you have used.
5digest_algorithm_oid = ObjectIdentifier.new(ObjectIdentifier::E_SHA256);
6signature_algorithm_oid = ObjectIdentifier.new(ObjectIdentifier::E_RSA_encryption_PKCS1);
7
8# Then, put the CMS signature components together.
9cms_signature = DigitalSignatureField.GenerateCMSSignature(
10 signer_cert, chain_certs, digest_algorithm_oid, signature_algorithm_oid,
11 signature_value, signedAttrs);
12
13# Write the signature to the document.
14doc.SaveCustomSignature(cms_signature, digsig_field, in_outpath);
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales