Downloading Backup Signature Instructions

Last updated: 2020-03-17 18:01:31


How to Sign the CDB Backup URL

Note: The secretId and signature in the example below are only for reference, and cannot be used in practice

1. Getting the Download URL

Method 1: Get the download URL on the console

Method 2: Get the download URL via API.

The obtained URL is as follows (sample):

2. Selecting an API Key for Signing the URL (The following key is only used as an example)

secretId: AKID1agWVShCU7cQxKh33n9w98kwxxxxxxx
secretkey: 7v64T1gUSB8hCazvDJUWxVxxxxxxxx

3. Signing the URL

The following signature example uses the above URL, secretId and secretkey

Step 1

Resolve the URL parameters and add secretId to get the following parameters:

appid: 8888888888,
time: 1478778522,
secretId: AKID1agWVShCU7cQxKh33n9w98kwxxxxxxx

Step 2

Sort the parameters in descending order based on key to get the following
Sorting result:

appid: 8888888888,
secretId: AKID1agWVShCU7cQxKh33n9w98kwxxxxxxx,
time: 1478778522

After combining the parameters:


Step 3

Use sha1 algorithm and secretkey to compute the combination of the parameters in Step 2 to get the signature, then encode it with Base64:


Step 4

Append the secretId and the generated signature to the end of the original URL to generate a new download URL and complete the signature:

Nodejs Sample Codes

var libUrl = require('url');
var crypto = require('crypto');
var libQuery = require('querystring');

function sign(url, SecretId, secretKey){
    //Resolve the download URL
    url += '&secretId=' + SecretId;
    var uinfo = libUrl.parse(url);
    var param = libQuery.parse(uinfo.query);

    //Sort the parameters
    var keys = Object.keys(param).sort();
    var sortUrl = [];
    for(var i in keys){
        sortUrl.push(keys[i] + '=' +param[keys[i]]);
    sortUrl = sortUrl.join('&');

    //Compute the signature
    var hmac = crypto.createHmac('sha1', secretKey);
    param['signature'] = hmac.update(new Buffer(sortUrl, 'utf8')).digest('base64');

    //Generate the new download URL
    var newUrl = 'http://' + + uinfo.pathname + '?';
    sortUrl = [];
    for(var i in param){
        sortUrl.push(i + '=' + encodeURIComponent(param[i]));
    newUrl += sortUrl.join('&');
    return newUrl;