Problem with signing pdf document

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

stefan.cacek
User
Posts: 3
Joined: Thu Feb 25, 2010 7:38 am

Problem with signing pdf document

Post by stefan.cacek »

Hi,

I migrate functionality connected with PDF document signing from SDK 3.5 to 4.0.
Certificates in solution are created using makecert (makecert.exe –r –pe –ss my –n cn=”MyCertificate”).

My solution worked fine with SDK 3.5 but in the same code with SDK 4.0 I receive error 0x80091002 “Unknown cryptographic algorithm.”.
When I generate certificate with algorithm (sha256, sha512) other then sha1 it works. But it works too with some sha1 certificates too.

In this moment I can’t regenerate all certificates connected with this solution, so I have the problem. hav You any idea how to signe document with sha1 certificate with SDK 4.0


Regards,
Stefan
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17949
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Problem with signing pdf document

Post by Tracker Supp-Stefan »

Hello Stefan,

have you tried catching the piece of code that throws this error and see if you can tune it slightly so that it doesn't cause those errors any more?

Also - if you cna provide us a snippet - we should be able to check the problem in more details.
Please make sure that your serial and dev codes are NOT visible in the snippet or we will need to deactivate them.

Best,
Stefan
stefan.cacek
User
Posts: 3
Joined: Thu Feb 25, 2010 7:38 am

Re: Problem with signing pdf document

Post by stefan.cacek »

This is a sample code

Code: Select all

	HRESULT hr ;
	PDFDocument pdf;

	hr = PXCp_Init(&pdf, "", "");

	hr =  PXCp_ReadDocumentW(pdf, L"e:\\a.pdf", 0);

	HCERTSTORE       hCertStore = NULL;       
	PCCERT_CONTEXT   pCertContext = NULL;   
	hCertStore = CertOpenSystemStore(NULL, L"MY");

             pCertContext = CryptUIDlgSelectCertificateFromStore(
                               hCertStore,      
                               NULL,
                               NULL, 
                               NULL,
                               CRYPTUI_SELECT_LOCATION_COLUMN,
                               0,
                               NULL);

            PXC_RectF sr;
            sr.left = I2L(1);
            sr.right = I2L(4);
            sr.top = I2L(3);
            sr.bottom = I2L(4);

            hr = PXCp_SignDocumentW(pdf, pCertContext, 0, &sr,  L"Test Reason", L"Test Location", L"Test Contact Info", L"E:\\1.jpg",
                      Sign_GR_Name | Sign_TX_Name | Sign_TX_Date |Sign_TX_Location | Sign_TX_Reason | Sign_TX_DName);
            //hr = 0x80091002 “Unknown cryptographic algorithm.”. 		  

            hr =  PXCp_WriteDocumentW(pdf, L"e:\\a123A.pdf", PXCp_CreationDisposition_Overwrite, (int)PXCp_Write_Release);
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17949
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Problem with signing pdf document

Post by Tracker Supp-Stefan »

Thanks Stefan,

We will take a look at this and advise as soon as possible.

Best,
Stefan
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: Problem with signing pdf document

Post by Ivan - Tracker Software »

To stefan.cacek: what OS do you use?
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
stefan.cacek
User
Posts: 3
Joined: Thu Feb 25, 2010 7:38 am

Re: Problem with signing pdf document

Post by stefan.cacek »

I tested it o English Windows Vista Business SP2 (x86) and Polish Window 7 SP1 (x86).
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17949
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Problem with signing pdf document

Post by Tracker Supp-Stefan »

Thanks for the update Stefan Cacek,

Ivan will take a look and reply as soon as possible.

Best,
Stefan
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3550
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: Problem with signing pdf document

Post by Ivan - Tracker Software »

I tested it o English Windows Vista Business SP2 (x86) and Polish Window 7 SP1 (x86).
And the results are the same as on XP ?
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.