FHIR Chat · fhircast-docs / Issue #41 Example HMAC digest does not eq... · fhircast-github

Stream: fhircast-github

Topic: fhircast-docs / Issue #41 Example HMAC digest does not eq...


view this post on Zulip Github Notifications (FHIRcast) (Mar 13 2019 at 08:10):

lbergnehr closed Issue #41

I've tried this for some time, but cannot get the request body of the example on fhircast.org to hash to what's in the X-Hub-Signature header. Just so I'm not missing anything, here's what I'm doing in ruby:

require 'openssl'

request_body = '{
  "timestamp": "2018-01-08T01:37:05.14",
  "id": "q9v3jubddqt63n1",
  "event": {
    "hub.topic": "https://hub.example.com/7jaa86kgdudewiaq0wtu",
    "hub.event": "open-patient-chart",
    "context": [
      {
        "key": "patient",
        "resource": {
          "resourceType": "Patient",
          "id": "ewUbXT9RWEbSj5wPEdgRaBw3",
          "identifier": [
            {
              "system": "urn:oid:1.2.840.114350",
              "value": "185444"
            },
            {
              "system": "urn:oid:1.2.840.114350.1.13.861.1.7.5.737384.27000",
              "value": "2667"
            }
          ]
        }
      }
    ]
  }
}'
secret = 'shhh-this-is-a-secret'

hash = OpenSSL::HMAC.hexdigest('sha256', secret, request_body);

puts hash

I'm getting 2e24e889827c4ab7ebd68217e12bf82d959dff4d12939e7b994fe0a197d19e1a and the example states dce85dc8dfde2426079063ad413268ac72dcf845f9f923193285e693be6ff3ae. I mean, they're not even close! :wink:

I've verified the above to work to some extent using wikipedia examples.

Something's off. Line-endings? Tabs vs. spaces? @isaacvetter, do you remember what you did when you wrote this?

view this post on Zulip Github Notifications (FHIRcast) (Mar 13 2019 at 08:10):

lbergnehr commented on Issue #41

I've thought long and hard on this and nothing came out so I'm closing this in favor of the online gods.


Last updated: Apr 12 2022 at 19:14 UTC