HTTP Response Signatures
Truework API responses include a signature header that can be used to verify the authenticity of the API response.
Public keys
Truework’s public key used to validate the signature will be published on this page.
Signature
The signature is included as a header named X-Truework-Signature and includes the information required to verify the signature.
The signature has three parts: keyId, headers and signature. For example:
Verifying the signature
Based on the headers part of the Signature header, we can construct the message that we will use to verify the signature.
The message contains the following components, separated by \n characters:
- Header key and value, in the format
headerKey: headerValue - Response body
For example, the message constructed for the API response:
Message constructed:
Using the constructed message, public key and signature, we can verify the response payload.
Code example
To verify the signature, we first parse the signature header to extract its parts:
We then construct the message that we will use to verify the signature:
Finally, we verify the message using the constructed message, Truework’s public key, and signature part: