Solved

Including hashed signature in HTTP header VB6

Posted on 2014-03-03
3
449 Views
Last Modified: 2014-03-03
Hi Experts -
I have VB6 code that I use to send an XML string to customer URL.
Recently, the customer asked us to include a digital signature in the header.
I've created the signature successfully and it is returned below as sDigSig.

I am not confident of the way I include the signature in HTTP header.
I've been all over the internet and have failed to find how this should be coded.

Please see the line below:
    objXmlHttp.setRequestHeader sDigSig, objDom.xml
below.

I think i need it to say something like:
    objXmlHttp.setRequestHeader  "Content-Type", "hash", sDigSig
but as i mentioned - i am coming up empty w/ the way I'm searching.

Also - we prefer to send this transmission asynchronously (timing is a premium).
Is this still possible to do when using .setRequestHeader ?

Thank you
klheitz

        Set objDom = CreateObject("MSXML2.DOMDocument")
        Set objXmlHttp = CreateObject("MSXML2.XMLHTTP")
       
        objDom.async = True    '07.26.13 change back to true

        '02.20.14 - digital sig to embed in http header...
        Dim sDigSig As String
        Dim objSig As New DigitalSignature.ComClass1
       
       
        sDigSig = objSig.GetSignature(strXML)
        Set objSig = Nothing        
       
        objDom.loadXML

            strPost = CUSTOMER_URL
                                   
            objXmlHttp.Open "POST", strPost, False
           
           
'***** // commented out
'     XMLHTTP.Open "POST", pstrURL, False ' False - syncronous mode
'
'    XMLHTTP.setRequestHeader "Content-Type", "text/xml"
'
'    XMLHTTP.setRequestHeader "X-Username", strUserName
'
'**** end comments

    objXmlHttp.setRequestHeader sDigSig, objDom.xml
                       
    objXmlHttp.Send objDom.xml
           
     strRet = objXmlHttp.responseText
0
Comment
Question by:klheitz
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
zc2 earned 500 total points
ID: 39901137
You should ask your client what the HTTP header parameter he expects to carry the signature. Let's assume, the parameter name is "X-Signature".
Then, instead of the line
  objXmlHttp.setRequestHeader sDigSig, objDom.xml
you need
  objXmlHttp.setRequestHeader "X-Signature", sDigSig

setRequestHeader has nothing to do with async type of request. The header will be set the same way as in the sync mode, before the request is actually sent.
0
 

Author Closing Comment

by:klheitz
ID: 39901347
Thank you! Exactly what I needed.
0
 
LVL 18

Expert Comment

by:zc2
ID: 39901404
You're welcome.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now