[ https://issues.apache.org/jira/browse/PDFBOX-4312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16617967#comment-16617967 ]
Tilman Hausherr edited comment on PDFBOX-4312 at 9/17/18 6:44 PM: ------------------------------------------------------------------ I'm afraid you haven't understood me. You cannot calculate the signature of the PDF before calling {{sign()}}. The input in {{sign()}} contains the signed PDF except the signature space. This signed PDF is more than the original PDF, some data (more than just the signature) is appended to the PDF. So if you are using an external service to calculate the signature, {{sign()}} must look somewhat like this: {code:java} public byte[] sign(inputStream is) { - pack the bytes from is (or a digest of it, don't know) into XML - send XML to external service - wait for response - check for error - receive XML response - extract signature bytes from XML response - return bytes } {code} If the point of you using an external service is to authenticate once, and then sign several files in one big batch, then this isn't possible in 1.8. It is possible in 2.0.11, see the source code of CreateVisibleSignature in the 2.0.11 source code download and the discussion in PDFBOX-3065. was (Author: tilman): I'm afraid you haven't understood me. You cannot calculate the signature of the PDF before calling {{sign()}}. The input in {{sign()}} contains the signed PDF except the signature space. This signed PDF is more than the original PDF, some data (more than just the signature) is appended to the PDF. So if you are using an external service to calculate the signature, {{sign()}} must look somewhat like this: {code:java} public byte[] sign(inputStream is) { - pack the bytes from is (or a digest, don't know) into XML - send XML to external service - wait for response - check for error - receive XML response - extract signature bytes from XML response - return bytes } {code} If the point of you using an external service is to authenticate once, and then sign several files in one bug batch, then this isn't possible in 1.8. It is possible in 2.0.11, see the source code of CreateVisibleSignature in the 2.0.11 source code download and the discussion in PDFBOX-3065. > byte array format to pass to sign method > ---------------------------------------- > > Key: PDFBOX-4312 > URL: https://issues.apache.org/jira/browse/PDFBOX-4312 > Project: PDFBox > Issue Type: Wish > Components: .NET, PDModel, Signing > Affects Versions: 1.8.9 > Reporter: bal > Priority: Major > > Hi , > I want to sign pdf using signature in pkcs 7 format . I am converting pkcs 7 > signature to byte array using Convert.FromBase64String method in .net . I am > passing this byte array to sign method in signature interface which gets > called after calling saveincremental. My byte array is inserting proper but > the name of which signature is not shown when i open pdf. May be my byte > conversion may not proper or something else i am doing wrong. please let me > know. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org