Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expiration needs to be set in UTC #41

Open
Prinzhorn opened this issue Jul 31, 2017 · 2 comments
Open

Expiration needs to be set in UTC #41

Prinzhorn opened this issue Jul 31, 2017 · 2 comments

Comments

@Prinzhorn
Copy link

Prinzhorn commented Jul 31, 2017

The defaultExpireTime uses the local time as do the examples in the docs. If you're ahead of UTC (e.g most of Europe) the links are expired as you create them. If you're behind UTC (e.g. all of USA) the links is valid longer than you think.

var defaultExpireTime = Math.round(Date.now() + 1800000);

There is not a really nice way in JavaScript without resorting to Moment.js or the like. https://stackoverflow.com/questions/948532/how-do-you-convert-a-javascript-date-to-utc

var now = new Date(); 
var nowUTC = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(),  now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
var defaultExpireTime = Math.round(nowUTC.getTime() + 1800000);

Moment.js

moment().utc().add(1, 'day')

screen shot 2017-07-31 at 11 08 28

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-creating-signed-url-custom-policy.html

{"AWS:EpochTime":required ending date and time in Unix time format and UTC}

@drone1
Copy link

drone1 commented Jul 24, 2018

This seems like a real issue. No updates since almost a year, though. What's the deal?

@hackash
Copy link

hackash commented Jan 28, 2019

If you check this line

https://github.com/jasonsims/aws-cloudfront-sign/blob/master/lib/CannedPolicy.js#L10

expireTime is divided into 1000 which makes it becomes compliant UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants