Audiohook http signature mismatch issue

Hi Genesys Developer Team,
After integrating the Audiohook API, I now want to verify the signature of the http message. I obtained a different signature when I generated one using the signature-inputs. Could you tell me what's wrong with this please.

Reference URL: https://developer.genesys.cloud/devapps/audiohook/session-walkthrough#establishing-connection
I used the reference url details, still generated with different hash like below.
Actual one generated from code : jEylAwtghWFWytY0R42pe7WFNidyisXPRETVpfhh+1o=

var crypto = require('crypto')
var secret = Buffer.from('TXlTdXBlclNlY3JldEtleVRlbGxOby0xITJAMyM0JDU=', 'base64')
var signature_base = "@request-target": /api/v1/voicebiometrics/ws "@authority": audiohook.example.com "audiohook-organization-id": d7934305-0972-4844-938e-9060eef73d05 "audiohook-session-id": e160e428-53e2-487c-977d-96989bf5c99d "audiohook-correlation-id": 30b0e395-84d3-4570-ac13-9a62d8f514c0 "x-api-key": SGVsbG8sIEkgYW0gdGhlIEFQSSBrZXkh "@signature-params": ("@request-target" "@authority" "audiohook-organization-id" "audiohook-session-id" "audiohook-correlation-id" "x-api-key");keyid="SGVsbG8sIEkgYW0gdGhlIEFQSSBrZXkh";nonce="VGhpc0lzQVVuaXF1ZU5vbmNl";alg="hmac-sha256";created=1641013200;expires=3282026430;
var sign_hash = crypto.createHmac('sha256', secret).update(signature_base).digest('base64')
console.log('computed hash : ',sign_hash);
var hash = 'NZBwyBHRRyRoeLqy1IzOa9VYBuI8TgMFt2GRDkDuJh4='
console.log('expected hash : ', hash);
if (hash === sign_hash) {
console.log('match') // logs => 'match'
} else {
console.log('no match')
}

Expected one from http header : NZBwyBHRRyRoeLqy1IzOa9VYBuI8TgMFt2GRDkDuJh4=

If this is working fine, then its easy for me to test this with my details.
Could you please go through the code and let me know if anything wrong.

Thank you!

Finally, I was able to get the Same Hash.

Issue was interchanged audiohook-session-id & audiohook-correlation-id values while documented.

If you correct those values, we will get same hash like
"audiohook-session-id": 30b0e395-84d3-4570-ac13-9a62d8f514c0
"audiohook-correlation-id": e160e428-53e2-487c-977d-96989bf5c99d

@Genesys Developer Team, Please update these values in your documentation. So that, it's easy for future developers who are referring the documentation for audio hook signature verification process.

Doc link: https://developer.genesys.cloud/devapps/audiohook/session-walkthrough#establishing-connection

Now i am facing an issue with the actual payload on the audiohook signature verification process.

Sample request:
{"x-forwarded-for":"xx.xx.xx.xx","host":"xxx-xxxxxxx.xxx","upgrade":"websocket","connection":"upgrade","x-real-ip":"xx.xx.xx.xx","x-forwarded-proto-scheme":"https","x-must-collect":"1","accept-encoding":"gzip","user-agent":"GenesysCloud-AudioHook-Client","audiohook-correlation-id":"52beaf5e-5ba7-493c-ba02-314648b5e85d","audiohook-organization-id":"ceaa3cb7-4f81-426f-8217-8fbfc171190d","audiohook-session-id":"611c1f0f-660e-46b9-b375-7a9d4b9b51a7","signature":"sig1=:P94QsJdsu+Mu9AFhAtQaM31gKuikv+9npOkru7qCPTA=:","signature-input":"sig1=("@request-target" "audiohook-session-id" "audiohook-organization-id" "audiohook-correlation-id" "x-api-key" "@authority");created=1679569110;expires=1679569120;keyid="SGVsbG8sIEkgYW0gdGhlIEFQSSBrZXkh";nonce="Rv93z/FZT7e36Hn2h/0ZPdmB";alg="hmac-sha256"","x-api-key":"SGVsbG8sIEkgYW0gdGhlIEFQSSBrZXkh","sec-websocket-key":"IeW3jeA10jK7TLJ1CCaapQ==","sec-websocket-version":"13","pragma":"no-cache","cache-control":"no-cache"}

Queries:

signature-input order got changed in real-time payload when compared to documentation example, which order you need to follow?
request-target means have to mention only the URI part which includes query params or not like below?
wss://test.example.com/integrations/genesysaudiohook?botId=xxxxxxxxxxxxxxxxxxx
authority means host name or different one which is configured in audiohook?

I am waiting for your reply, please respond ASAP.

Hi Pavan,

There is also these page with some additional information about the client authentication:

https://developer.genesys.cloud/devapps/audiohook/security#client-authentication

At the end of this section, you will find the following statement:

IMPORTANT

Implementers should not assume the client will only use the listed signature parameters or HTTP header fields and order as shown in examples and test vectors in this document. Implementers are encouraged to support as much of Signing HTTP Messages as possible or practical. Genesys reserves the right to include other parameters, derived components, or HTTP header fields in future releases. We may support other signature algorithms in addition to "hmac-sha256" in the future too, but they will be made configurable though the integration configuration.

Basically, the server needs to follow whatever is listed in the "signature-input" header (derived components, headers and order of elements). The documentation only shows a few examples and should not be used as the source of truth.

I hope this helps.

Thanks,
Camiel

Hi Camiel,

Thank you for your reply on this. Yes, we followed the same link as a reference and tried all possibilities to verify the signature. I will try to connect with you/team shortly to showcase a live use-case demo.

Regards,
Pavan.K

Sorry Pavan, I missed your other 2 questions. In terms of request-target and authority, I can't be clearer than the IETF draft:

Request-target: draft-ietf-httpbis-message-signatures-11

Authority: draft-ietf-httpbis-message-signatures-11

Thanks,
Camiel

Hi Pavan,

There is indeed a bug at the client side when query parameters are used in the URI.

For instance, this URI: "wss://genesys.com/api/v1/some/route?bot=123456&language=en-US" was producing the following @request-target: /api/v1/some/routebot=123456&language=en-US. As you can see, the ? is missing. This would mess up the whole signature.

I am opening a ticket and the fix will probably be deployed by the end of next week.

Thanks,
Camiel

Hi Camiel,
Thank you for taking the time to look into it and sharing this. Please let me know once the bug is fixed and deployed.

Thanks
Pavan.K

Hi Pavan,

The bug should be fixed now.

Thanks,
Camiel

Thank you Camiel for this update. We will check and get back to you, if anything required.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.