Signing a Request Using RSA

For successful completion, follow the steps and examples below.

How to compute the signature with RSA

1

Prepare the payload

Convert the data to be signed (signature payload) into ASCII format. This payload typically includes all relevant request parameters or fields.

2

Generate the binary signature

Use the RSASSA-PKCS1-v1_5 signing algorithm with the SHA-256 hash function and your RSA private key to create a binary signature.

3

Encode the signature

Convert the binary output of the signature to a Base64 string (RFC 2045).

How to send a signed API request

Once the signature has been created, you can include it in your API request:

Add the Signature to the request header

Use the Base64-encoded signature generated in the previous step.

Include your API Key

Add your Quentrade API Key in the header alongside the Signature.

Send the request

Make the request to a SIGNED endpoint. Ensure the payload, headers, and method match the data used to compute the signature to avoid mismatches.

Keep in mind, the signature is case sensitive.

Examples & Interactive Generator

Below is a real-world example of signing a request using RSA with Quentrade API endpoints, along with an interactive calculator tool.

The following is a step-by-step guide for generating a valid RSA signature and sending a signed payload using Linux openssl, cURL, or the interactive tool below.

api_key.txt
vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A
private_key.pem
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAspMfrKDl78gMWr4EO9Nr9LoZirPvkN93oGDO1LPnvDIwkmTVQCXv9EAgzz4E36B9RuXIukMydrwCqtPOaweSAFgj9MZ0PFwIWsHk4x7flUJU3YI3Ub2uc+jl2Mbtxfoei5cbY6iAwsp+HyeKrdonVHtEd9mFutd468+vO7+rx/M80oncfduNVf/GRR2McTOO4Ptm4s68clY0dyXMRLidQjydPPYNjuzs47DVxNK+tXGS7QSHLuC7VO/YBXWqZNzvii1KeCEIePJfz06ywZFTdNxZt2USoudAgUMBvJg0cLKqQJFxp62Pez6aWC0lV9yDPHpUwp+RfrNiP213vKObnQIDAQABAoIBAQCf//KBWiirjzKCm35vnB8+RwBbpp0f0Rn+OL8ZFZispsueX3oy38r/rfW3unnjZIja3UfcnBi7CfnZ1a09eKr4ZADTcHz1GADkUJYkaaUqtyQS1Hl8Y9fLQwGuGY8xs8lq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UFjEzHD5k=
-----END RSA PRIVATE KEY-----

Request Parameters

Parameter:mode|Value:paper
query_string.txt
query
path: /api/v1/user/mode
queryString: mode=paper
payload: /api/v1/user/mode?mode=paper

Generating the Signature

generate_signature.sh
$openssl dgst -sha256 -sign private.pem

After running the command, you'll get the signature:

signature_base64.txt
W+a26NiV6KkWP5zWoaDU9nSHmfObAtbbaq+xPIKwiKIz81Mlgrek/Z51qsAWNXEMCpIGW40IYDo7BTq4FSvOVSxdfrFK3lRqBveoXW+/50QOd3p+fDe5Ku7Z0U6MvXSUeFOguMBxP7er1SLGOb5RLYI/2GPMI5txLAoSsTLjGkWOc7S3ZhUpxEfxSCp8wCFp6E99biIX2MhIT1/AAl290ID76Wr1dj9Y3QxIl6KtQlbpEqhvWBaadYaYyZR5YjHAn5NWAE2cvxLkH+SQE1khzAdB6T9ZJ9sgMtY1bOzTTV/Cj9W0SABCYr4In12+uFY0lB+ANvgi8hLr2NCl775Wdw==

Making the API Call

execute_request.sh
cURL
curl -X POST 'https://quentrade.com/api/v1/user/mode?mode=paper' \
  -H 'APIKEY: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A' \
  -H 'Signature: W+a26NiV6KkWP5zWoaDU9nSHmfObAtbbaq+xPIKwiKIz81Mlgrek/Z51qsAWNXEMCpIGW40IYDo7BTq4FSvOVSxdfrFK3lRqBveoXW+/50QOd3p+fDe5Ku7Z0U6MvXSUeFOguMBxP7er1SLGOb5RLYI/2GPMI5txLAoSsTLjGkWOc7S3ZhUpxEfxSCp8wCFp6E99biIX2MhIT1/AAl290ID76Wr1dj9Y3QxIl6KtQlbpEqhvWBaadYaYyZR5YjHAn5NWAE2cvxLkH+SQE1khzAdB6T9ZJ9sgMtY1bOzTTV/Cj9W0SABCYr4In12+uFY0lB+ANvgi8hLr2NCl775Wdw=='