Some test text!

menu
Verify a documentkeyboard_arrow_down

Verify a signature in C++

Try our experimental web demo for digital signature verification.

EXPERIMENTAL FEATURE. Digital signature verification is undergoing active development, but currently does not support a number of features. If we are missing a feature that is important to you, or if you have files that do not act as expected, please contact us using one of the following forms: https://www.pdftron.com/form/trial-support/ or https://www.pdftron.com/form/request/

To verify all cryptographic digital signatures in a document:

// Open an existing PDF
PDFDoc doc(in_docpath);

// Choose a security level to use, and change any verification options you wish to change
PDF::VerificationOptions opts(PDF::VerificationOptions::e_compatibility_and_archiving);

// Trust a binary DER X509 certificate
std::vector<UInt8> trusted_cert_buf;
Filters::MappedFile trusted_cert_file(in_public_key_file_path);
size_t file_sz = trusted_cert_file.FileSize();
Filters::FilterReader file_reader(trusted_cert_file);
trusted_cert_buf.resize(file_sz);
file_reader.Read(&trusted_cert_buf.front(), file_sz);
opts.AddTrustedCertificate(&trusted_cert_buf.front(), trusted_cert_buf.size());

// Iterate over the signatures and verify all of them.
DigitalSignatureFieldIterator digsig_fitr = doc.GetDigitalSignatureFieldIterator();
for (; digsig_fitr.HasNext(); digsig_fitr.Next())
{
    DigitalSignatureField curr = digsig_fitr.Current();
    VerificationResult result = curr.Verify(opts);
    if (result.GetVerificationStatus())
    {
        cout << "Signature verified" << endl;
    }
    else
    {
        cout << "Signature verification failed" << endl;
    }
}

Digital signatures
Full code sample which demonstrates using the digital signature API to digitally sign, certify, and/or verify PDF documents.

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.