Unable to specify Digital Certificate
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
-
- User
- Posts: 20
- Joined: Wed Jul 16, 2008 8:38 am
Unable to specify Digital Certificate
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
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
- Tracker Supp-Stefan
- Site Admin
- Posts: 17910
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Unable to specify Digital Certificate
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
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: 3549
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
- Contact:
Re: Unable to specify Digital Certificate
To specify binary data, you can pass them as a SAFEARRAY or BSTR.
Here is a sample how to specify using BSTR:
HTH
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);
}
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.
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.
-
- User
- Posts: 20
- Joined: Wed Jul 16, 2008 8:38 am
Re: Unable to specify Digital Certificate
That works fine - many thanks!
Nick Tucker
Nick Tucker
- Tracker Supp-Stefan
- Site Admin
- Posts: 17910
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Unable to specify Digital Certificate
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
Thanks in advance.
Happy new year!
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
Thanks in advance.
Happy new year!
- Tracker Supp-Stefan
- Site Admin
- Posts: 17910
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Unable to specify Digital Certificate
Happy New Year cpi software,
Let's continue this in the separate topic that you started.
Cheers,
Stefan
Let's continue this in the separate topic that you started.
Cheers,
Stefan
Re: Unable to specify Digital Certificate
Fine, thanks.Tracker Supp-Stefan wrote:Let's continue this in the separate topic that you started.
- 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
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
Thank you.
Best regards
Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com