All Products
Search
Document Center

URL signing

Last Updated: May 27, 2021

URL signing is available only for the JSON API of Alibaba Cloud Public DNS. URL signing can be used to authenticate users and prevent malicious traffic.

API description

Note

Sample signed URL

http://223.5.5.5/resolve?name=aliyun.com&type=A&uid=9999&ak=test&key=fb321ab77496a89c04de0a1e979bfee4b4678a0dcd57f4da1da83644a490f64b&ts=1614927253

Parameters for URL signing

Parameter

Description

Data type

Example

uid

The ID of the user whose identity needs to be authenticated.

A value of the unsigned integer type.

uid=9999

ak

The AccessKey ID for authentication.

The AccessKey ID of the string type. You can obtain it on the Public DNS page of the Alibaba Cloud DNS console.

ak=test

key

The hash string for authentication.

The signature that is generated by using the AccessKey secret.

key=fb321ab77496a89c04de0a1e979bfee4b4678a0dcd57f4da1da83644a490f64b

ts

The timestamp.

A value of the unsigned integer type, which is the number of seconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

ts=1614927253

Key generation algorithm

key = sha256(uid+userKey+ts+qname+ak)

Note: The plus sign (+) indicates that the strings are concatenated. 

In the preceding code, the value of the uid parameter is a string that is converted from a number. For example, if the ID of the user is 9999, set the value of the uid parameter to 9999 as a string. The value of the userkey parameter is the AccessKey secret that is obtained on the Public DNS page of the Alibaba Cloud DNS console. The value of the ts parameter is also a string that is converted from a number. The value of the qname parameter is the domain name that the user wants to resolve. The value of the ak parameter is the AccessKey ID that is obtained on the Public DNS page of the Alibaba Cloud DNS console.

Key generation sample

Note

Example:

uid=9999

userkey=12345

ak=test

qname=aliyun.com

ts=1614927253 (2021-03-15 11:04:22)

key=sha256(10001123451614927253aliyun.comtest)

=>

key=fb321ab77496a89c04de0a1e979bfee4b4678a0dcd57f4da1da83644a490f64b

Final request:

http://223.5.5.5/resolve?name=aliyun.com&type=A&uid=9999&ak=test&key=fb321ab77496a89c04de0a1e979bfee4b4678a0dcd57f4da1da83644a490f64b&ts=1614927253

Others

We recommend that you use Public DNS SDKs to access Public DNS. The SDKs contain the code for URL signing. You do not need to implement URL signing by yourself.