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: Tracker Support, TrackerSupp-Daniel, Chris - Tracker Supp, Vasyl-Tracker Dev Team, 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 » Fri Dec 12, 2014 11:12 am

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: 13320
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Unable to specify Digital Certificate

Post by Tracker Supp-Stefan » Fri Dec 12, 2014 2:44 pm

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

Ivan - Tracker Software
Site Admin
Posts: 3587
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Unable to specify Digital Certificate

Post by Ivan - Tracker Software » Fri Dec 12, 2014 6:06 pm

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 » Mon Dec 15, 2014 9:44 am

That works fine - many thanks!

Nick Tucker

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

Re: Unable to specify Digital Certificate

Post by Tracker Supp-Stefan » Mon Dec 15, 2014 11:22 am

:)

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

Re: Unable to specify Digital Certificate

Post by Guillermo » Tue Jan 10, 2017 11:55 am

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
http://help.tracker-software.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: 13320
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Unable to specify Digital Certificate

Post by Tracker Supp-Stefan » Tue Jan 10, 2017 4:03 pm

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 » Tue Jan 10, 2017 5:56 pm

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: 6661
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Unable to specify Digital Certificate

Post by Will - Tracker Supp » Wed Jan 11, 2017 8:20 am

:)
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