PDF Signer
The PDF signer has the class name: org.signserver.module.pdfsigner.PDFSigner.
Overview
The main purpose of the PDF signer is to add digital signatures to PDF documents.
The signer supports the addition of visible or invisible signatures. Both visible and invisible signatures serve the same purpose of signing a document, and technically are equivalent in that sense. The difference is that when a visible signature is applied to a document, a signature image (in the shape of a rectangle) is placed at the specified place in the document. Clicking the signature image displays the properties of the signature (Adobe Acrobat Reader).
In contrast, when applying an invisible signature, the signature properties are accessed via menu items. For visible signatures, properties such as custom signature image, signature rectangle, page at which the signature rectangle will be drawn, and so on can be specified (see Worker Properties).
PDF Signer can also apply a timestamp to a signature. If the signature is timestamped, the timestamp can be viewed through signature properties in Adobe Acrobat Reader. Timestamping is used to prove that the document was signed before the time specified by the timestamp token. If the signature is not timestamped, the signature time specified in the signature properties is not considered to be trusted.
It is strongly advised to apply a timestamp to a signature. You can use the TSA module for this purpose.
Also, the CRL or OCSP Response of the signer's certificate can be embedded inside the signature package. Embedding the CRL or OCSP response with the package helps validate the signature even after the signer's certificate is expired. However, embedding the response does not guarantee long-term signature preservation. The topic of long-term signature preservation for archival purposes is a large one and is discussed to be implemented in future versions of SignServer.
The PDF Signer can also be configured to enforce that certain PDF permissions are not available in the signed document or that certain permissions should be removed.
PDF Passwords
PDF documents can optionally be protected by a password. There are two different types of passwords:
User Password: Also sometimes referred to as "open password" or "document password". Can be used for reading an encrypted document.
Owner Password: Also sometimes referred to as "permission password" or "security restriction password". It can be used for reading an encrypted document and making changes to a document that has permissions.
If a document is protected by an Owner password, it has to be supplied with the request for SignServer to sign the document. If the document is protected by a User password, either the User password or the Owner password has to be supplied with the request for SignServer to sign the document.
PDFSigner Requests
PDF signing requests can be served using either web services or the web server interface (HTTP). See SignServer Integration for general information about the different interfaces.
For the web server interface, the GenericProcessServlet can be used. The PDFSigner supports the extra request field "pdfPassword" letting the client supply a PDF password to be used for opening the PDF for signing (not required unless the PDF is already password protected).
For the old web services interface, the request should contain an encoded GenericProcessesRequest and the response will be a GenericProcessResponse. It is possible to supply a PDF password by including it in the requestMetaData with the key "pdfPassword".
Worker Properties
The following properties can be configured with the signer:
Property | Default | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ADD_VISIBLE_SIGNATURE | False | Controls whether the signature to be added should be visible (true) or invisible (false). | ||||||||||||
ALLOW_PROPERTY_OVERRIDE | Not set (no properties are allowed to be overridden) | Comma-separated list of worker properties that are allowed to be overridden by request metadata properties with the same names. See Request Metadata Properties for a list of properties that can be added to this property. | ||||||||||||
ALLOW_SIGNING_WITHOUT_OWNERPASSWORD | False | By default, the PDF Signer requires the owner's password to sign a PDF that has PDF permissions set. Setting | ||||||||||||
APPEND_SIGNATURE | Not set | Set to false if the document has no signature and the PDF Signer should not use the appended signature. The PDF Signer then instead rewrites the document and uses an embedded signature. Setting to false resolves a potential issue with PDFs in format versions 1.6-1.7 and ensures that the PDF is rewritten and that the previous signature is not invalidated. Setting this property to true or to an invalid value is the same as leaving this property unset. | ||||||||||||
ARCHIVETODISK | False | If you want the produced signed document to be stored in the local file system, set this property to true and add the | ||||||||||||
ARCHIVETODISK_FILENAME_PATTERN | ${WORKERID}-${REQUESTID}-${DATE:HHmmssSSS}.pdf | Pattern used for creating the filename. You can use the same fields and syntax as for the | ||||||||||||
ARCHIVETODISK_PATH_BASE | The file path to the folder to store the signed documents. To be able to use this property, you must ensure that the directory where archived documents are written is on the allowlist. See Deploy-time Configuration. | |||||||||||||
ARCHIVETODISK_PATH_PATTERN | ${DATE:yyyy/MM/dd} | Pattern used for creating sub-folders under the | ||||||||||||
CERTIFICATION_LEVEL | NOT_CERTIFIED | Set this property to have the document certified with a certifying signature. | ||||||||||||
DIGESTALGORITHM | SHA256 | Sets the hash algorithm used for the message digest and signature hash.
Setting the | ||||||||||||
EMBED_CRL | False | To embed the CRL for the signer certificate inside the signature package, set to True. Otherwise, set to False. | ||||||||||||
EMBED_OCSP_RESPONSE | False | To embed the OCSP response for the signer certificate inside the signature package, set to True. Otherwise, set to False. Issuer certificate (of signing certificate) should be in the certificate chain. OCSP responses must contain a nextUpdate field in order for offline validation to work with Adobe Reader. For EJBCA OCSP Responder, see configuration of | ||||||||||||
LOCATION | SignServer | The location included in the PDF signature and displayed by the PDF reader. | ||||||||||||
REASON | Signed by SignServer | The reason included in the PDF signature and displayed by the PDF reader. | ||||||||||||
REFUSE_DOUBLE_INDIRECT_OBJECTS | False | True if PDF documents containing multiple indirect objects with the same name should be refused. Use to mitigate a collision signature vulnerability described in http://pdfsig-collision.florz.de/ . | ||||||||||||
REJECT_PERMISSIONS | Unset/empty (no permissions are rejected) | Reject signing of the document if any of the permissions in the comma-separated list would be in the document. Available permissions (from the PDF reference, version 1.6, page 99, TABLE 3.20): | ||||||||||||
REMOVE_PERMISSIONS | Unset/empty (no permissions are removed) | Remove all permissions specified in this comma-separated list from the document. See the available permissions in This property cannot be specified if you use This property only removes the permissions listed even if some permissions (such as | ||||||||||||
SET_OWNERPASSWORD | Unset | Sets the specified password as the owner password in the document. The SET_OWNERPASSWORD property uses the same permissions as before (unless other properties change the permissions). The property uses the same encryption algorithm as the original document. If the original document did not use any encryption, the property uses the default encryption algorithm. If the permissions are changed, the existing owner password is used. If no such password is used in the document, a semi-random password is created. | ||||||||||||
SET_PERMISSIONS | Unset (permissions are not set by this property) | Replace the current permissions (if any) with the permissions specified in this comma-separated list of permissions. See the available permissions in This property cannot be specified if This property and the If the document is not already protected by an owner password and the | ||||||||||||
TSA_DIGESTALGORITHM | SHA-256 | (Optional) Algorithm for timestamp digests. | ||||||||||||
TSA_URL | Not set (no timestamping) | If you want to timestamp the document signature, specify the timestamp authority URL. If path contains characters "\" or "=" , these characters should be escaped (thus "\" = "\\", "=" =>"\="). Cannot be set at the same time as TSA_WORKER. | ||||||||||||
TSA_USERNAME & TSA_PASSWORD | Not set (TSA does not require authentication) | If the TSA requires authentication for timestamping, specify username and password. If the TSA does not require authentication, do not set these properties. These properties are ignored if TSA_URL is not set (no timestamping). | ||||||||||||
TSA_WORKER | Not set (no timestamping) | Specify a worker ID or worker name for a time stamp signer. Use instead of Cannot be set at the same time as TSA_URL. | ||||||||||||
VISIBLE_SIGNATURE_CUSTOM_IMAGE_BASE64 & VISIBLE_SIGNATURE_CUSTOM_IMAGE_PATH | Not set (no custom image) | If you want the visible signature to contain a custom image, specify the image as base64 encoded byte array. Alternatively, the custom image can be specified by giving a path to the image on the file system. If both properties are set,
This property is ignored if In a clustered environment, it is advised to specify the image as a base64 string, since image data will be stored in a central database. Otherwise, each node should contain a copy of the image, and each image managed separately (such as on image updates, or insertion of a new image for a different worker). In order to use the | ||||||||||||
VISIBLE_SIGNATURE_CUSTOM_IMAGE_RESIZE_TO_RECTANGLE | True | To resize a custom image to a specified rectangle (set by This property is ignored if | ||||||||||||
VISIBLE_SIGNATURE_RECTANGLE | 400,700,500,800 | Specifies the rectangle that the signature is going to be drawn in.
This property is ignored if | ||||||||||||
VISIBLE_SIGNATURE_PAGE | First | Specifies the page on which the visible signature will be drawn. Possible values:
This property is ignored if |
Request Metadata Properties
The following properties can be sent by the client with the request:
With the exception of pdfPassword, these Metadata properties are only allowed if listed in ALLOW_PROPERTY_OVERRIDE.
Property | Description |
|---|---|
ADD_VISIBLE_SIGNATURE | Overrides the worker property with the same name. |
CERTIFICATION_LEVEL | Overrides the worker property with the same name. |
DIGESTALGORITHM | Overrides the worker property with the same name. |
EMBED_CRL | Overrides the worker property with the same name. |
EMBED_OCSP_RESPONSE | Overrides the worker property with the same name. |
LOCATION | Overrides the worker property with the same name. |
pdfPassword | User/open password to use for reading the PDF if it is password protected. Does not need to be listed in |
REASON | Overrides the worker property with the same name. |
REJECT_PERMISSIONS | Overrides the worker property with the same name. |
REMOVE_PERMISSIONS | Overrides the worker property with the same name. |
SET_OWNERPASSWORD | Overrides the worker property with the same name. |
SET_PERMISSIONS | Overrides the worker property with the same name. |
SIGNERCERTCHAIN | Overrides the worker property with the same name. |
USE_TIMESTAMP | Overrides the worker property with the same name. |
VISIBLE_SIGNATURE_CUSTOM_IMAGE_BASE64 | Overrides the worker property with the same name. |
VISIBLE_SIGNATURE_CUSTOM_IMAGE_RESIZE_TO_RECTANGLE | Overrides the worker property with the same name. |
VISIBLE_SIGNATURE_NAME | Sets the visible signature in the existing empty signature filed with this name. |
VISIBLE_SIGNATURE_PAGE | Overrides the worker property with the same name. |
VISIBLE_SIGNATURE_RECTANGLE | Overrides the worker property with the same name. |