Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / December 2005

Tip: Looking for answers? Try searching our database.

Programmatically signing an InfoPath form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MarcusRosen@gmail.com - 05 Dec 2005 01:18 GMT
Hi,

I'm attempting to programmatically sign an infopath form (bypassing the
Digital Signing Wizard) but I keep getting an invalid signature error
after the form has been signed.

I'm using the code found in the following two articles, expect for
changing the certificate name and passing the name of the section to be
signed rather than hard-coding it, etc:

Digitally Signing Data in InfoPath 2003
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ip2003_ta/h
tml/ODC_INFDigitallySigningData1.asp


Verify and Add Digital Signatures to Form Data in InfoPath 2003 Using
MSXML 5.0 or .NET Framework Managed Code
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_ip2003_ta/h
tml/ODC_INFDigitallySigningData2.asp


At first I thought maybe my certificate (self-created) was corrupt but
I can sign a form using the digital signing wizard with the same
certificates.

The form has been set up in the following way:

The form has got a section called UserData that has been configured to
be signed with 1 signature through the section properties.

The form has got a button which event handler invokes the OnSign event
like this:

[InfoPathEventHandler(MatchPath="CTRL37",
EventType=InfoPathEventType.OnClick)]
public void CTRL15_5_OnClick(DocActionEvent e)
{

    thisXDocument.SignedDataBlocks[0].Sign();
}

My OnSign Event creates an instance of my signaturehelper class,
passing a reference to the infopath document instance, along with the
certificate name and store name and the name of the section to be
signed (for creation of the signature ID). The code inside the external
assembly (SignatureHelper) contains the code from the articles above.

[InfoPathEventHandler(EventType=InfoPathEventType.OnSign)]
public void OnSign(SignEvent e)
{
    // create Digital Signature Helper and pass document instance
    SignatureHelper helper = new SignatureHelper( ref thisXDocument );
    helper.SignForm(e, "My", "mrosen",
thisXDocument.SignedDataBlocks[0].Name);

    // Set return status to ignore invoking the Wizard
    e.ReturnStatus = true;
}

I have made the form trusted through by using the Macro described in
the InfoPath SDK documentation and I can step through all the code etc.

The code executes fine, no errors occurs but after the code finishes
its execution, the area that normally holds the signature details etc
says "There is a problem with the signature" and clicking to see more
details it comes up with ??? for the certificate name and some of the
properties populated like date of signing etc

I have at this point serialised the instance out to a file and it
contains all the signature sections, with the certificate and other
details.

It seems like the form is modified after it has been signed making the
signature invalid or somthing similar.

Any help would be appreciated as I feel I'm running out of options.

Cheers,
Marcus
MarcusRosen@gmail.com - 05 Dec 2005 02:32 GMT
Never mind, problem solved!! :)

The problem was the actual certificate. Once I issued a proper
certificate (with an exportable key) using OpenSSL it works perfectly!

See this guide for how to:
http://www.madboa.com/geek/openssl/#verify-standard

Cheers,
Marcus
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.