signedpdf | A Python library for digitally signing PDFs | Document Editor library
kandi X-RAY | signedpdf Summary
kandi X-RAY | signedpdf Summary
A Python library for digitally signing PDFs
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Return the value as a byte string
- Encode a name
- Encode an object
signedpdf Key Features
signedpdf Examples and Code Snippets
Community Discussions
Trending Discussions on signedpdf
QUESTION
I do apply a signature to a pdf document via delayed signing(SignDeferred) using IText. The process contains the following steps:
- Prepare the pdf document for siging
- Reserve space for the signature in the pdf document
- Create the hash value of the pdf document
- Create the signature based on the hash value
- Using a self signed certificate
- Apply the signature to the pdf document
The whole process works and i end with a pdf document where the signature is set and is valid.
The original pdf is a PDF-A1a but the resulting pdf is not a valid PDF-A1a anymore. I am aware that there is a documentation about IText PDF-A support (https://kb.itextpdf.com/home/it7kb/ebooks/itext-7-jump-start-tutorial-for-java/chapter-7-creating-pdf-ua-and-pdf-a-documents), but this seems to not apply since i don't change the content of the document.
My question: How can i apply a signature using deferred signing and keep the PDF-A1a in the resulting document?
Note: If i do apply a signature directly (Without SignDeferred), the resulting pdf is still a PDF-A1a, but i do have to use SignDeferred Note: I do use https://www.pdfen.com/pdf-a-validator for checking pdf-A
Code sample- Component used for signing:
- itext.sign 7.1.5.0
- itext.kernel 7.1.5.0
- Component used for creating hash
- BouncyCastle.Crypto 1.8.1.0
The following is a complete code sample sample with everything required in one file. It only requires the references to itext and BouncyCastle and the path to a self signed certificate
...ANSWER
Answered 2020-Nov-27 at 08:00It seems the reason why the signed pdf is no longer a valid PDF-A1a is the estimated size for the signature. I have used a value of about 120kb for the signature.
QUESTION
Everyone.
Every function on a controller, I am using the same variables.
...ANSWER
Answered 2020-Jul-28 at 23:16Normally you can directly set things in the constructor but there is an issue with Controllers in regards to middleware. The Controller is resolved before the request has passed through the middleware stack. Which means you usually won't have things like sessions or auth available yet. You would want to use a closure based middleware in the constructor of the Controller to be able to set this value:
QUESTION
I sign the pdf files with this code (I use itextsharp):
...ANSWER
Answered 2020-Jul-23 at 23:00I would like to know why my signature goes in the side panel and instead the one I find in the other files is located at the bottom of the page and is visible immediately. How can I show my signature on the page as shown in the image (*IMG2)?
Your signature has no visualization in the document because you created it as an invisible signature (firma invisibile)! If you want to create a visible signature, you have to tell iText where that visualization shall go. You do that using the PdfSignatureAppearance
method SetVisibleSignature
:
QUESTION
I am trying to add multiple signatures with iTextSharp 5.5.13.1.
Only the last signature is valid.
And all previous signatures are invalid with the message:
"Document has been altered or corrupted since it was signed" - 1 Page(s) Modified
I don't necessarily need certified signatures.
I use signature append mode but still can't figure out what modifies the document.
In notepad the first part of document till the second signature seems unchanged.
The code I used is:
...ANSWER
Answered 2020-May-16 at 10:41Your code as is adds an image to the static content of a page. That is forbidden to do to a signed file. For details on allowed and disallowed changes to a signed PDF read this answer.
According to your code comments, though, you also tried to alternatively add the image to the signature appearance. That is not forbidden as such. But analyzing the provided example PDFs it becomes apparent that in this attempt additional content streams have been added to the page. Even though they essentially are empty, this is considered a change of page content which is disallowed.
As it turned out, you didn't add the image to the page content in this attempt but you still retrieved the OverContent
of the page:
QUESTION
PDF document needs to signed with national digital identity.
National digital identity WebService provide facility to sign document, in my project I have integrated same.
Requesting Esign services give response in PKCS7(CMS)
format.
I want to append same response in multiple locations, So i am creating multiple empty signature container post i receive Response from service.
I referred this article : Sign Pdf Using ITextSharp and XML Signature
But in given article we only one signing location is present but i have multiple signing locations.
I am using itext
sharp Library.
Using MakeSignature.SignDeferred
Method to append signature at multiple locations but it is showing PDF invalid.
Please find below response XML which i received from Webservice:
...ANSWER
Answered 2019-Mar-25 at 14:53A first quick look through your code revealed two major errors.
Hashing twiceYou hash the document data twice (using different APIs for that... weird!):
QUESTION
I'm implementing an application to sign PDF files in the server, with the follow scenario (to make long history, short):
- Client start signature sending to server, date/time and watermark
- Server add signature dictionaries into file and send data to be signed
- Client sign content
- Server finish the signature
I'm using PDFBox 2.0.15, and making use of new feature saveIncrementalForExternalSigning
as shown in the code below:
ANSWER
Answered 2019-Jul-04 at 17:08Thanks to Tilman Hausherr I could figure out what was going on:
1 - I have a Desktop APP that communicates with SmatCards and so on, and it is the signer. To communicate with the server (through a webpage) we use WebSocket. I've written my own websocket server class, and that is why it's only prepared to work with 65k bytes. Than when I tried to send the data here:
QUESTION
I try to digitally sign a pdf using an external web service. This web service contains the user certificate, which the user can access with their credentials and a one time password generated code.
Sidenote: The web service is supposed to expect the pdf digest (hash), but strangely it accepts the whole file instead.
Anyway the implementation is as follows:
...ANSWER
Answered 2020-Feb-11 at 09:39Since the signature that I receive does not contain a timestamp from a timestamp server, can I embed such a timestamp at this point or should the remote web service add it before sending the signature to me?
Such a time stamp is added to the signature container as unsigned attribute. Because they are not signed, unsigned attributes in a signature container can be changed after applying a signature, e.g. additional ones can de added.
Thus, you yourself can in particular add a time stamp to the signature container retrieved from your service.
Depending on the nature of your signatures, though, you might have to increase the size of the placeholder you create in the pdf to have enough space for the additional time stamp.
QUESTION
This is extended question from this question : add revocation detail in pdf while signing same
I have signed a pdf using itextsharp
library and .net core (c#).
after signing pdf I added LTV using AdobeLtvEnabling
class from previous question. - Till here pdf is working fine.
But when I am trying to embed timestamp in signature, it embeds but in AdobeLtvEnabling
class's enable method in verification it throws exception :
Signer SHA256WITH1.2.840.10045.4.3.2 not recognised
Below is the code method for signing:
...ANSWER
Answered 2019-Dec-30 at 13:53I was trying with wrong pair of DSC (USB token) and timestamp URL. That was the reson it was throwing exception to me while adding LTV.
Then I tried with actual global sign dsc and url embedded in it's property of x509 extension then it worked and I was able to sign PDF : zeta-uploader.com/browse/897639557
Reference Code for fetching timestamp URL:
QUESTION
First of all, although I've been following StackOverflow for quite some time, it is the first time I posted something, so if I do something wrong or not according to the rules, please feel free to point me in the right direction.
I'm developing a PDF digital signature application, using iText5, which depends on an external service to provide a signed hash after I prepare the PDF for signing.
As described in iText documentation, in the first phase I prepared the PDF (in the final implementation, all PDFs may be multi signed, so I use append mode), like so:
...ANSWER
Answered 2019-Feb-08 at 13:27There are a number of issues in your code.
First of all your code mixes different iText signing API generations. There is the older API generation which requires you to work very near to the PDF internals, and there is the newer (since version 5.3.x) API which is implemented as a layer over the older API and does not require you to know those internals.
The "Digital Signatures for PDF documents" white paper focuses on showing the newer API, only section 4.3.3 "Signing a document on the server using a signature created on the client" uses the old API because the use case does not allow for the use of the newer API.
Your use case does allow for the use of the newer API, though, so you should try and use only it.
(In certain situations one can mix those APIs, but you then should really know what you're doing and still can get it awfully wrong...)
But now some more specific issues:
Working on closed objectsThe MakeSignature.Sign*
methods implicitly close the underlying PdfStamper
and SignatureAppearance
objects, so working with those objects thereafter should not be assumed to result in sensible information.
But in GetBytesToSign
you do
QUESTION
Using iTextSharp
to create and sign a PDF works fine. but when I open the document in Adobe Reader or Acrobat it displays
“At least one signature has problems”
Note: This is not the same as a similar known problem:
"At least one signature is invalid"
Which actually indicates that the certificate is invalid.
After reading a bit on the net, specially on Adobe forum, it seems that Adobe does not recognize the certificate as trusted. I have tried both self-signed certificate and an official verified and validated certificate we purchased from thawte that we use for code signing without any issues.
I can almost understand this warning for a self-signed certificate, but not for an official and commercial certificate bought from thawte.
All the "solutions" out there suggest that a user can manually add the certificate to a so called trusted list. the process is described here:
How to resolve “At least one signature has problems.” error in Adobe Reader?
The problem will be "solved" for that specific user/computer, but if you send the PDF to another customer, the message appears again!
That seems like a very unprofessional behavior. and this warning is just misleading and makes it much worst for the simple end-customers not knowing if they can trust the signed document!
What can be does to fix this issue?
If Adobe is selling a special certificate for PDF, we are willing to perches such certificate! is that an option?
I have searched all over, but could not find a proper solution.
The code I'm using:
...ANSWER
Answered 2019-Jul-23 at 17:21What can be does to fix this issue?
If Adobe is selling a special certificate for PDF, we are willing to perches such certificate! is that an option?
I have searched all over, but could not find a proper solution.
By default Adobe Reader trusts certificates with issuers from Adobe's own AATL (Adobe Authorized Trust List) and the EUTL (European Union Trust List).
For details read Adobe Trust Services:
Adobe facilitates trusted and secure exchange of electronic documents and information by means of trust services that enable individuals, governments and enterprises around the world to run their businesses safely based on principles of Security, Availability, Authenticity, Integrity, Confidentiality, and Privacy.
Adobe Authorized Trust List (AATL)The Adobe Approved Trust List (AATL) is the largest Trust Service for electronic documents in the world allowing millions of users to create digital signatures that are trusted whenever the signed document is opened in the ubiquitous Adobe Acrobat or Acrobat Reader software. Over 6 billion electronic and digital signature transactions are processed through Adobe Document Cloud solutions every year.
Acrobat and Acrobat Reader have been programmed to reach out to an online service run by Adobe to periodically download a list of trusted digital certificates from leading Trust Service Providers.
Digital signatures created with a Digital ID that has been issued under any of the trustworthy certificates published in the AATL will appear as trusted in Acrobat and Acrobat Reader. This enormously simplifies the validation of these signatures without requiring any specialized software or custom configuration.
Visit the Adobe Authorized Trust List web page to know more about the AATL program and view the list of partners that provide trusted AATL Digital IDs.
Adobe European Union Trust List (EUTL)EU Trusted lists are essential elements in building trust among electronic market operators by allowing users to determine the qualified status and the status history of trust service providers and their services.
The Adobe European Union Trust List (EUTL) is a reduced version of the combined trusted lists from all EU Member States and EEA countries which includes the information specified in Article 1 of European Commission Implementing Decision (EU) 2015/1505.
Some Member States may include in their trusted lists information on non-qualified trust service providers, but these services are excluded from the Adobe EUTL. Some Member States may also include in their trusted lists information on nationally defined trust services of other types than those defined under Article 3(16) of EU Regulation n. 2014/910. As these services are not qualified according to EU Regulation n. 2014/910, they are excluded as well from the Adobe EUTL.
Acrobat and Acrobat Reader have been programmed to reach out to an online service run by Adobe to periodically download the list of trusted digital certificates from EU Qualified Trust Service Providers that meet the requirements specified in Article 1 of the Implementing Decision (EU) 2015/1505.
Digital signatures created with a Digital ID that has been issued under any of the trustworthy certificates published in the EUTL will appear as trusted in Acrobat and Acrobat Reader. This enormously simplifies the validation of these signatures without requiring any specialized software or custom configuration.
Visit Adobe’s European Union Trust List (EUTL) web page to know more about the EUTL program and view a list of providers that issue EUTL trusted services.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install signedpdf
You can use signedpdf like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page