Cloudinary uses digital signatures both to verify the integrity of a message and to provide authentication for communicating over the Internet using the HTTP protocol. Signatures can help ensure that the message was not tampered with during transit and provide an additional layer of security to ensure that even if the transport channel has been compromised, the contents can still be verified.

Cloudinary's SDKs take care of the signature generation where needed for communication with Cloudinary, so you will only need to manually write the code for generating a signature when NOT using our SDKs or when you want to verify a signature that was sent from Cloudinary.

The following table summarizes Cloudinary's signature usage and the payload signed in each case.

Signature usage Example use case Payload to sign
Generating authentication signatures Authenticating a POST request A string with the parameters used in the POST request to Cloudinary:

  • All parameters added to the method call should be included except: file, cloud_name, resource_type and your api_key.
  • Add the timestamp parameter.
  • Sort all the parameters in alphabetical order.
  • Separate the parameter names from their values with an = and join the parameter/value pairs together with an &.
Note: Separate multiple values for any array parameters with commas (e.g., public_ids=cat,dog,lion).
Verifying notification signatures Verifying a signature in the header of a notification sent from Cloudinary A string containing the entire response body with the X-Cld-Timestamp value appended on the end of the string.
Generating delivery URL signatures The signature component of a signed delivery URL of the format:
A string including all the components of the delivery URL that will come after the signature component.
Verifying signatures in the JSON response Verifying the signature parameter returned in the response to a method call. A string with the public_id and version parameters, separated from their values with an = and then joined together with an &.

Signature generation

To generate the signature, append your API secret to the end of the payload to sign described above, and then create a hexadecimal message digest (hash value) of the string using an SHA cryptographic function.

By default, Cloudinary supports both SHA-1 and SHA-256 digests for validation, and you can use either. The SDK methods use the SHA-1 algorithm by default, but you can use the SHA-256 algorithm instead by setting the signature_algorithm SDK configuration parameter to sha256. If you want to limit your account to allow only the SHA-256 digest for all your validations, submit a request.

For example:

Copy to clipboard
require 'digest'
signature = Digest::SHA1.digest(payload_to_sign + api_secret)
Copy to clipboard
signature = sha1($payload_to_sign . $api_secret)
Copy to clipboard
import hashlib
signature = hashlib.sha1(payload_to_sign + api_secret).hexdigest()
Copy to clipboard
var sha1 = require('sha1');
var signature = sha1(payload_to_sign + api_secret);
Copy to clipboard
import static org.apache.commons.codec.digest.MessageDigestAlgorithms.SHA_224;
string signature = DigestUtils.sha1Hex(payload_to_sign + api_secret)

✔️ Feedback sent!

Rate this page: