Previous Digital Signature Information lost when adding new Digital Signature


#1

I am using aspose.pdf-17.2.0 for java. I have a scenario:
a- I added digital Signature and saved the PDF File (File-After-First-Signautre.pdf), There it is showing correctly Signature information .
b- Now added an other digital Signature in File-After-First-Signautre.pdf, saved the file with name File-After-Second-Signautre.
Here it is showing new signature’s information but the previous signature’s information is lost, It is saying signed by unknown. Previous Signature should be Invalidate, but information should not be lost.

I attached both pdf files and also attached the image of 2nd pdf, where it is showing signature Information.

This is my Code:

			certificateInformation=getCertificateInformation(usercode);
		String d=(String) certificateInformation.get("d");
			if(d.isEmpty()){
				
				String certificatePwd=(String) certificateInformation.get("certificatePwd");
				String certificatePath=(String) certificateInformation.get("certificatePath");
				
				PKCS7 signature = new PKCS7(certificatePath, certificatePwd);
				
				Rectangle rectangle	=new Rectangle(x,y,width,height);
				
				PdfFileSignature pFileSignature = new PdfFileSignature();

				pFileSignature.bindPdf(pdfFilePath);
				
				pFileSignature.sign(pageNo, false, rectangle,signature );
			
			
				
				pFileSignature.setSignatureAppearance(signatureImagePath);
			

				String url = clsStaticData.getServiceParamValue(CTSCService.SERVICE_NAME_CTSC, "RootDirectoryPath", "");
				
				String outPutPDFFilename = "signed" + UUID.randomUUID().toString()+".pdf";
				String outSignedFile = url + "temp\\"+ outPutPDFFilename;
				
				
				pFileSignature.save(outSignedFile);
				
				
				
				
				obj.put("error", "");
				obj.put("outputFile", outSignedFile);
			
			}else{
				
				obj.put("error", "Certificate does not exist");
				
				
			}

File-After-First-Signautre.pdf (119.7 KB)
File-After-Second-Signautre.pdf (165.6 KB)
PDF-Signature-After two Signatures.PNG (42.0 KB)


#2

@mukhan12

Thank you for conacting support.

Would you please share the PFX file and its password as well so that we may try to reproduce and investigate it further. You may share it as ZIP privately with me by clicking on my username and then message icon. Before sharing requested data, please ensure using Aspose.PDF for Java 19.10 in your environment.


#3

@Farhan.Raza

Thank you for timely response,

I shared with you PFX files of two users, and I tried Aspose.PDF for Java 19.10 also, same result.


#4

@mukhan12

Thank you for sharing requested data.

We have considered first signed document as source file and then executed following code with Aspose.PDF for Java 19.10. Generated documents have been attached for your kind reference. Would you please check these and share screenshots if you notice the problem.

String certificatePath = dataDir + "cma3.pfx";
PKCS7 signature = new PKCS7(certificatePath, certificatePwd);
java.awt.Rectangle rectangle = new java.awt.Rectangle(100,100,200,200);
PdfFileSignature pFileSignature = new PdfFileSignature();
pFileSignature.bindPdf(dataDir + "File-After-First-Signautre.pdf");
pFileSignature.sign(1, false, rectangle,signature );
pFileSignature.save(dataDir + "Signed_cma3_19.10.pdf");

Signed_cma3_19.10.pdf
Signed_usman_19.10.pdf


#5

Dear Farhan,
I used Aspose.PDF for Java 19.10. But still have same issue,
Please see this screen shot.
PDF with two Signatures.PNG (55.2 KB).


#6

@mukhan12

Would you please share the generated PDF document as well as your environment details including OS and JDK information. Please also ensure using a valid license because we are unable to reproduce the problem in our environment.


#7

@Farhan.Raza
Hi Farhan,
My license is working fine with 17.2, But giving error with 19.2, should I need to purchase new License ? I will purchase it, but i need to make sure that this issue will be solved in 19.2 version ,with valid licence.

This is the generated document.
2ndwithAspose19-10.pdf (246.3 KB)


#8

@mukhan12

Please ensure testing it with free 30-days temporary license. You may apply for temporary license on the given link and evaluate latest version of the API as per your requirements. Kindly share your environment details so that we may check if the issue is environment specific as we are unable to reproduce it in Windows 10.


#9

Hi Farhan,

I tried with temporary License, and used aspose-pdf-19.10.jar. Same issue I faced again,
I am doing this on Windows 10, using Java 1.8.0_181.
This is the output file.
2ndSignature.pdf (150.5 KB)


#10

@mukhan12

Thank you for details.

We have logged an investigation ticket with ID PDFJAVA-39008 in our issue managment system and we will let you know once any further update will be available in this regard.