1

Please see this post for the same issue in .

Here is my main code:

loadFile "md5.vbs"
wscript.echo "md5('test') = " & md5("test")
loadFile "sha256.vbs"
wscript.echo "sha256('test') = " & sha256("test")

method = "POST"
app_id = <redacted>
key = "<redacted>"
secret = "<redacted>"
tstamp = datediff("s",#1970/1/1#,dateadd("h",5,now()))

data = "{""data"":{""message"":""hello world""},""name"":""my_event"",""channel"":""test_channel""}"
path = "/apps/" & app_ID & "/events"
query = "body_md5=" & md5(data) & "&auth_version=1.0&auth_key=" & key & "&auth_timestamp=" & tstamp
sig = sha256(method & vbLf & path & vbLf & query & vbLf & secret)

url = "https://api.pusherapp.com" & path & "?" & query & "&auth_signature=" & sig
wscript.echo url
dim xmlhttp 
set xmlhttp = Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.Open method,url,false
xmlhttp.setRequestHeader "Content-Type", "application/json"
xmlhttp.send data
WScript.echo xmlhttp.responsetext
Set xmlhttp = nothing

md5.vbs can be found here and sha256.vbs here.

I get this error:

Invalid signature: you should have sent HmacSHA256Hex("POST\n/apps/(redacted)/events\nauth_key=(redacted)&auth_timestamp=1471291494&auth_version=1.0&body_md5=(redacted)", your_secret_key), but you sent "(redacted)"

(code edits: Added secret to sig, changed crlf to lf)

9
  • You're using vbCrLf (\r\n) line breaks, whereas I presume vbLf (\n-only) line breaks are expected. Commented Aug 15, 2016 at 20:27
  • I replaced the 2 instances of vbCrLf with vbLf and get the same error. Commented Aug 15, 2016 at 20:35
  • So what's the exact difference (save for the redacted parts) between the "should" and "is" strings in the error message at this point? Is it just the MD5 value? Commented Aug 15, 2016 at 20:45
  • Yes, the "You sent" is a hash. Commented Aug 15, 2016 at 20:46
  • I don't understand the HMacSHA256Hex(param1, your_secret_key) thing at all. Commented Aug 15, 2016 at 20:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.