[][src]Function cloudfront_policy_signer::create_canned_policy_signature

pub fn create_canned_policy_signature(
    resource: &str,
    expiry: u64,
    private_key_location: &str
) -> Result<String, Error>

Signs a canned policy with the specified path and expiration date and returns it in an URL safe format appropriate for AWS.

See CloudFront Documentation for more details

Arguments

  • resource - The protected resource eg. https://example.cloudfront.net/flowerpot.png
  • expiry - Absolute time that the link expires, given in the form of a unix timestamp in UTC
  • private_key_location - Path where the private key file can be found

Example

use cloudfront_url_signer;

fn main() {
   let resource = "https://example.cloudfront.net/flowerpot.png";
   let expiry = 1579532331;
   let certificate_location = "examples/key.pem";
   let key_pair_id = "APKAIEXAMPLE";

   let signature = cloudfront_url_signer::create_canned_policy_signature(resource, expiry, certificate_location).unwrap();

   println!("Signed URL is {}", format!("{}?Expires={}&Signature={}&Key-Pair-Id={}", resource, expiry, signature, key_pair_id));
}