Binance Pay is introducing a new platform certificate for webhook signatures. Webhooks signed with
it carry BinancePay-Certificate-SN-New and BinancePay-Signature-New next to the existing
headers, see Webhook Common Rules. This API returns the
list of public keys for BinancePay-Signature-New. Find the public key for a webhook in this list
by the BinancePay-Certificate-SN-New header.
Always get the public key from this API. Do not hard-code it in your code or configuration: Binance Pay can replace the certificate, and a hard-coded key stops verifying from that moment.
EndPoint
Code
The request is signed like every other Binance Pay API request, see API Common Rules. It takes no request parameters.
Response Parameters
| Attributes | Type | Required | Limitation | Description |
|---|---|---|---|---|
| status | string | Y | "SUCCESS" or "FAIL" | status of the API request |
| code | string | Y | - | request result code, refer to API Common Rules |
| data | List(Certificate) | Y | - | certificate list, refer to |
| errorMessage | string | N | maximum length 256 |
data is a list, not a single certificate:
- Each element is one certificate, identified by its
certSerial. - The list can hold more than one certificate, for example while Binance Pay replaces the certificate. It is empty until Binance Pay enables the new certificate; a non-empty list means webhooks now carry the new headers.
- The order of the elements has no meaning. Find the certificate for a webhook by its
BinancePay-Certificate-SN-Newheader, see Find the Public Key by the Webhook Header. /binancepay/openapi/certificatesdoes not return these certificates.
Child Attribute
Certificate
| Attributes | Type | Required | Limitation | Description |
|---|---|---|---|---|
| certSerial | string | Y | 32-character uppercase hexadecimal | Certificate serial number. Equals the BinancePay-Certificate-SN-New header of the webhooks this certificate signs, character for character: compare the two as exact strings |
| certPublic | string | Y | - | Public key (PEM) of this certificate. Verifies BinancePay-Signature-New of a webhook whose BinancePay-Certificate-SN-New equals certSerial |
Sample Response
Code
Find the Public Key by the Webhook Header
- Call this API and cache
dataas a map fromcertSerialtocertPublic. - When a webhook arrives, read its
BinancePay-Certificate-SN-Newheader. - Look up that value in the map. The matching
certPublicis the public key that verifies the webhook'sBinancePay-Signature-New. Never pick a key by its position indata, such as the first or the last element. - If the value is not in the map and the map was rebuilt less than a minute ago, reject the webhook without calling this API. Otherwise call this API again, rebuild the map, and reject the webhook if the value is still not found. Anyone who can reach your webhook URL can send an unknown value, so never call this API once per webhook. Binance Pay retries a rejected webhook, so a genuine webhook signed by a certificate you have not cached yet passes on a later retry.
- Refresh the cache at least once a day, even when no unknown value appears.
Was this page helpful?
Last modified on