Page 1 of 1

Unable to specify Digital Certificate

Posted: Fri Dec 12, 2014 11:12 am
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

Re: Unable to specify Digital Certificate

Posted: Fri Dec 12, 2014 2:44 pm
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

Re: Unable to specify Digital Certificate

Posted: Fri Dec 12, 2014 6:06 pm
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

Re: Unable to specify Digital Certificate

Posted: Mon Dec 15, 2014 9:44 am
by nick.tucker
That works fine - many thanks!

Nick Tucker

Re: Unable to specify Digital Certificate

Posted: Mon Dec 15, 2014 11:22 am
by Tracker Supp-Stefan
:)

Re: Unable to specify Digital Certificate

Posted: Tue Jan 10, 2017 11:55 am
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!

Re: Unable to specify Digital Certificate

Posted: Tue Jan 10, 2017 4:03 pm
by Tracker Supp-Stefan
Happy New Year cpi software,

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

Cheers,
Stefan

Re: Unable to specify Digital Certificate

Posted: Tue Jan 10, 2017 5:56 pm
by Guillermo
Tracker Supp-Stefan wrote:Let's continue this in the separate topic that you started.
Fine, thanks.

Re: Unable to specify Digital Certificate

Posted: Wed Jan 11, 2017 8:20 am
by Will - Tracker Supp
:)