Solved

Including hashed signature in HTTP header VB6

Posted on 2014-03-03
3
465 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Visual Studio 2005 text editor 10 44
clicking a shape in a frame array vb6 3 47
AL3 Files 4 39
How to implement an additional command 16 40
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

821 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