Related Articles

4 Comments

  1. 1

    Guest

    Excelent!!!

    Reply
  2. 2

    Prabhath

    when I run the above script, I am getting the below error:
    ValueError: No PEM start marker

    Note: I gave the priv_key_file as .pem file

    Could u please help me on this

    Reply
    1. 2.1

      Onur SALK

      Hi,

      This should be an issue with python, maybe your version.

      Reply
  3. 3

    Mahtab Alam (@alammahtab08)

    Just wanted to add this, to generate Signed URLs with Node.js

    https://aws.amazon.com/blogs/developer/creating-amazon-cloudfront-signed-urls-in-node-js/

    npm install aws-cloudfront-sign

    var cfsign = require(‘aws-cloudfront-sign’);

    var currentTime = new Date()
    var currentTimeinMillis = currentTime.getTime();
    console.log(“—————————————————————————“)
    console.log(‘Current Time is ‘+currentTime)
    var expiryTime = currentTimeinMillis + 1*60*1000;
    console.log(“—————————————————————————“)
    console.log(‘Signed URL wiil expire on ‘+new Date(expiryTime));

    var signingParams = {
    keypairId: process.env.KEY_PAIR_ACCESS_KEY_ID,
    privateKeyPath: ‘/Users/mahtab.alam/Downloads/cloudfront-key-pair-private-key.pem’,
    expireTime: expiryTime
    }

    // Generating a signed URL
    var signedUrl = cfsign.getSignedUrl(
    ‘http://xxxxxxxxxxxxxx.cloudfront.net/cat1.jpeg’,
    signingParams
    );

    console.log(“—————————————————————————“)
    console.log(‘Signed URL ‘)
    console.log(“—————————————————————————“)
    console.log(signedUrl)

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.