Page 1 of 1

PDF digital signature - Cannot find object or property. (Exception from HRESULT: 0x80092004)

Posted: Tue Sep 22, 2020 10:13 am
by Zmaster
I am looking for cause or solution for the following exception:
Cannot find object or property. (Exception from HRESULT: 0x80092004)

Problem occur on the following line of code:
DFXCoreAPI.IPXC_Document.WriteToFile(String sDestFileName, IProgressMon pProgress, UInt32 nFlags)

For testing I am using certificate issued by CA with purpose of digital signatures, so there should be no problem with certificate itself. Also, problems does not occur on every machine that I have tested it, just one or two.

Here is the code I am using:

Code: Select all


PXC_Rect signatureRect = new PXC_Rect()
{
	left = rect.Value.left,
	top = rect.Value.bottom - 1,
	right = rect.Value.left + PDF_SIGNATURE_WIDTH,
	bottom = rect.Value.top - PDF_SIGNATURE_HEIGHT - 1
};

byte[] certBuffer = cert.RawData;

contextPointer = CertCreateCertificateContext(PKCS_7_OR_X509_ASN_ENCODING, certBuffer, certBuffer.Length);

UnsafeMethods.DeferedDigitalSignEx(doc, contextPointer, PXC_SignDocumentFlags.Sign_TX_Labels | PXC_SignDocumentFlags.Sign_TX_Name | PXC_SignDocumentFlags.Sign_TX_Date, pageNo, signatureRect, SIGN_REASON, SIGN_LOCATION, SIGN_CONTACT_INFO, null);

doc.WriteToFile(targetPath, null, (int)PXC_DocumentWriteFlags.DocWriteFlag_Incremental);
And the implementation of DeferedDigitalSignEx:

Code: Select all

public static void DeferedDigitalSignEx(IPXC_Document doc, IntPtr pointer, PXC_SignDocumentFlags flags, int pageIndex, PXC_Rect position, string reason, string location, string contact, string imagePath)
{
	unsafe
	{
		_CERT_CONTEXT* contextStructPointer = (_CERT_CONTEXT*)pointer;

		doc.DeferedDigitalSign(ref *(contextStructPointer), (uint)flags, (uint)pageIndex, position, reason, location, contact, imagePath);
	}
}
Edit: Same certificate works from Acrobat Reader and PDF-XChange Editor

Re: PDF digital signature - Cannot find object or property. (Exception from HRESULT: 0x80092004)

Posted: Wed Sep 23, 2020 2:10 pm
by Paul - PDF-XChange
Hi Zmaster,

I have reached out to the dev team member who is best able to address this and he is otherwise engaged today. He will look at your post/question tomorrow.

regards

Re: PDF digital signature - Cannot find object or property. (Exception from HRESULT: 0x80092004)

Posted: Thu Sep 24, 2020 5:37 pm
by Paul - PDF-XChange
Hi Zmaster,

can you please test signing a document using the same certificate on the same machine using the Stand alone Editor? We want to see if this is specific to the SDK or the Editor in general.

Re: PDF digital signature - Cannot find object or property. (Exception from HRESULT: 0x80092004)

Posted: Fri Oct 02, 2020 9:24 am
by Zmaster
It turned out that problem was not library.

Looks like certificate middleware didn't work without latest Windows update.

Re: PDF digital signature - Cannot find object or property. (Exception from HRESULT: 0x80092004)

Posted: Fri Oct 02, 2020 9:26 am
by Sasha - PDF-XChange
Hello Zmaster,

Case closed then?

Cheers,
Alex