Unable to specify Digital Certificate

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

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

Post Reply
nick.tucker
User
Posts: 20
Joined: Wed Jul 16, 2008 8:38 am

Unable to specify Digital Certificate

Post by nick.tucker »

Hi there

I am attempting to use the V4 API SDK to digitally sign newly created PDF files via the code snippet below in the context of a successfully created instance:

m_pPrinter->ResetDefaults();
m_pPrinter->Option[L"Save.SaveType"] = L"Save";
m_pPrinter->Option[L"Save.ShowSaveDialog"] = L"No";
m_pPrinter->Option[L"Save.File"] = L"test.pdf";
m_pPrinter->Option[L"Save.WhenExists"] = L"Overwrite";
m_pPrinter->Option[L"Save.RunApp"] = FALSE;
m_pPrinter->Option[L"Overlay.Enabled"] = FALSE;
m_pPrinter->Option[L"Compression.Graphics"] = TRUE;
m_pPrinter->Option[L"Compression.Text"] = TRUE;
m_pPrinter->Option[L"Fonts.EmbedAll"] = FALSE;
m_pPrinter->Option[L"Saver.ShowProgress"] = FALSE;

m_pPrinter->Option[L"Digisig.Enabled"] = TRUE;
const char *hash="\xa2\xaa\xa1\x4e\xca\x9d\x3c\xee\xf1\x2b\x6b\xf4\x2f\x4f\x6c\x86\x0d\x5e\xf3\xf1";
m_pPrinter->Option[L"Digisig.Hash"] = hash;

m_pPrinter->ApplyOptions(0);

The problem I'm having is that the "Digisig.Hash" value is specified in the help as 'Binary', and it's not clear to me how such values should be presented to the API. Presumably you must specify which certificate you want to use by specifying its hash value, by which I think you mean the Thumbprint value as specified against the key in the Windows Certificate Manager. That is a 20-byte binary value, so no standard integer formats are big enough - you can see I've tried presenting it as a binary string, but that also doesn't seem to work.

What am I doing wrong here?

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

Re: Unable to specify Digital Certificate

Post by Tracker Supp-Stefan »

Hello Nick,

I've checked this quickly with a colleague from the dev team, but it seems like we will need some imput from a colleague in the Canadian office. So I've now forwarded your question to the correct person and we will post again here when we have more info on how the Hash is to be used.

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

Re: Unable to specify Digital Certificate

Post by Ivan - Tracker Software »

To specify binary data, you can pass them as a SAFEARRAY or BSTR.

Here is a sample how to specify using BSTR:

Code: Select all

// If you are using ATL, you can use CComBSTR
CComBSTR bin;
bin.AppendBytes(hash, strlen(hash));
m_pPrinter->Option[L"Digisig.Hash"]	= bin;

// or just use API calls
BSTR bin = ::SysAllocStringByteLen(hash, strlen(hash));
if (bin != nullptr)
{
    m_pPrinter->Option[L"Digisig.Hash"]	= bin;
    ::SysFreeString(bin);
}
HTH
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.
nick.tucker
User
Posts: 20
Joined: Wed Jul 16, 2008 8:38 am

Re: Unable to specify Digital Certificate

Post by nick.tucker »

That works fine - many thanks!

Nick Tucker
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17765
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Unable to specify Digital Certificate

Post by Tracker Supp-Stefan »

:)
Guillermo
User
Posts: 13
Joined: Thu Apr 24, 2014 3:58 pm

Re: Unable to specify Digital Certificate

Post by Guillermo »

Hi to All!

I would like these code in vb.net or vb6, thus signing and how to convert the hash text to binary in order to pass the info to the driver.

Also, as some people has commented, there is an error in the name, sometimes DigSig and others DigiSig
https://help.pdf-xchange.com/DEV/de ... natures.29
(not sure if linking help pages works)
please see the attached image
Image

Thanks in advance.
Happy new year!
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17765
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Unable to specify Digital Certificate

Post by Tracker Supp-Stefan »

Happy New Year cpi software,

Let's continue this in the separate topic that you started.

Cheers,
Stefan
Guillermo
User
Posts: 13
Joined: Thu Apr 24, 2014 3:58 pm

Re: Unable to specify Digital Certificate

Post by Guillermo »

Tracker Supp-Stefan wrote:Let's continue this in the separate topic that you started.
Fine, thanks.
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Unable to specify Digital Certificate

Post by Will - Tracker Supp »

:)
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
Post Reply