Solved

Including hashed signature in HTTP header VB6

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

863 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

19 Experts available now in Live!

Get 1:1 Help Now