Unsuccessfull test of digital signing in VB6

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

aisoft
User
Posts: 20
Joined: Fri Jul 24, 2009 1:59 pm

Unsuccessfull test of digital signing in VB6

Post by aisoft »

Hello,

I have installed current demo release of PDF-XChange Drivers. When I set digital signature properties (certifacate etc.) manually in printer options, and then print anything, everything works fine an I get signed PDF file. But when I try to do the same things programmatically, no error is displayed, everything looks normal, but I get the file without digital signature.

Here is my code:

Option Explicit

Const SW_MINIMIZE = 11
Private Declare Function ShellExecute Lib "Shell32" Alias "ShellExecuteA" (ByVal hwnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Command1_Click()
Dim pFactory As New PXCComLib.CPXCControlEx
Dim pPrinter As PXCComLib.CPXCPrinter
Dim pname As String

Set pPrinter = pFactory.Printer("", "PDF-XChange 4.0 Sample", "<YOUR REG CODE>", "<YOUR DEV CODE>")
pname = pPrinter.Name
With pPrinter
.ResetDefaults
.Option("Save.File") = "c:\testsigned.pdf"
.Option("Save.SaveType") = "Save"
.Option("Save.ShowSaveDialog") = "No"
.Option("Save.WhenExists") = "Overwrite"

'Digital signature
.Option("DigiSig.Enabled") = True
.Option("DigiSig.Store") = "1"
.Option("DigiSig.PFXPath") = "c:\pokus2.pfx"
.Option("DigiSig.PFXPassword") = "PASS888"
.Option("DigiSig.Reason") = "Reason test field"

'Compression off
.Option("Compression.Graphics") = "No"
.Option("Compression.Text") = "No"

.Option("Saver.ShowProgress") = "No"
.ApplyOptions 0
End With
ShellExecute 0, "printto", "c:\test.doc", """" + pname + """", vbNull, SW_MINIMIZE
End Sub
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Unsuccessfull test of digital signing in VB6

Post by Corwin - Tracker Sup »

.Option("DigiSig.PFXPath") = "c:\pokus2.pfx"
Dont you mean to do this? :

Code: Select all

.Option("DigiSig.PFXFile") = "c:\pokus2.pfx"
;)
HTH
aisoft
User
Posts: 20
Joined: Fri Jul 24, 2009 1:59 pm

Re: Unsuccessfull test of digital signing in VB6

Post by aisoft »

Corwin, thank you very much, it worked.

I wonder why the line .Option("DigiSig.PFXPath") = "c:\pokus2.pfx" does not throw exception.

Would it be possible to incorporate some verification of input values into next build of your product ? For example it may throw exception in the cases of setting non-existing option, setting incorrect value of the option, certifcate file does not exist, incorrect password for certificate, certificate with given Hash not found etc. Lot of developers would strongly welcome it. (And you would not need to answer such a questions :) )

I have a hash of the installed certificate in the form of hexadecimal numbers separated by spaces. In which form may I set it to DigiSig.Hash option ? Is it possible to use certificate installed in system, when it is password-protected ?
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Unsuccessfull test of digital signing in VB6

Post by Corwin - Tracker Sup »

Hi aisoft,

In next build if you try to specify wrong option name then you will get an exception. Thanks for pointing that out :)
I have a hash of the installed certificate in the form of hexadecimal numbers separated by spaces. In which form may I set it to DigiSig.Hash option ?
Sorry, such possibility will be available only in new build..
First you should convert it to byte array (VT_ARRAY | VT_BYTE) and then write this byte array to Hash option.
Is it possible to use certificate installed in system, when it is password-protected ?
We have not seen any certificate installed in system which was password protected. Are you sure that system storage allows doing such things?
aisoft
User
Posts: 20
Joined: Fri Jul 24, 2009 1:59 pm

Re: Unsuccessfull test of digital signing in VB6

Post by aisoft »

Hello Corwin
Corwin - Tracker Sup wrote:We have not seen any certificate installed in system which was password protected. Are you sure that system storage allows doing such things?
Yes, it allows. When you import the certificate with private key from .pfx file into your storage, you can set the private key security to high and choose the password. This password is then required for any use of private key.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: Unsuccessfull test of digital signing in VB6

Post by Ivan - Tracker Software »

Thanks, I see.
And during signing of PDF file you will need to enter your password. There are no way to provide this password via options, and I'm not sure we can/will provide such a feature.
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.
aisoft
User
Posts: 20
Joined: Fri Jul 24, 2009 1:59 pm

Successfull test of digital signing in VB6

Post by aisoft »

The password entry dialog should be displayed by the layer which computes the signature. To incorporate this feature into the program may be possible, but it's another story. :lol:
aisoft
User
Posts: 20
Joined: Fri Jul 24, 2009 1:59 pm

Re: Unsuccessfull test of digital signing in VB6

Post by aisoft »

Hello,
When I make signed PDF, am I able to detect whether the signing proces was succesfull and the resulting PDF is signed ?
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17960
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Unsuccessfull test of digital signing in VB6

Post by Tracker Supp-Stefan »

There were comments in this topic that were for the end user Viewer, but in one of my posts I moved I had an answer to aisoft, hence this post.

aisoft,

This is not possible with the current builds. I will request an answer from the development team as to if and when it will be possible.

Regards,
Stefan
aisoft
User
Posts: 20
Joined: Fri Jul 24, 2009 1:59 pm

Re: Unsuccessfull test of digital signing in VB6

Post by aisoft »

Hello Stefan, did you get an answer for the question above ?
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Re: Unsuccessfull test of digital signing in VB6

Post by Ivan - Tracker Software »

No, via Driver API SDK you can only be notified if file was saved, if there were issues signing the document, the document will be created without a signature.

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.