By j10


2017-05-17 06:42:53 8 Comments

I am trying a small example with AWS API Gateway and IAM authorization. The AWS API Gateway generated the below Endpoint :

https://xyz1234.execute-api.us-east-2.amazonaws.com/Users/users

with POST action and no parameters.

Initially I had turned off the IAM for this POST Method and I verified results using Postman it works. Then I created a new IAM User and attached AmazonAPIGatewayInvokeFullAccess Policy to the user thereby giving permission to invoke any API's. Enabled the IAM for the POST Method.

I then went to Postman - and added Authorization with AccessKey, Secret Key, AWS Region as us-east-2 and Service Name as execute-api and tried to execute the Request but I got InvalidSignatureException Error with 403 as return code.

The body contains following message :

Signature expired: 20170517T062414Z is now earlier than 20170517T062840Z (20170517T063340Z - 5 min.)" 

What am I missing ?

4 comments

@Abhishek Jain 2019-06-12 07:18:01

Faced similar issue when I use timedatectl command to change datetime of underlying machine... Explanation given by MikeD & others are really informative to fix the issue....

sudo apt install ntp
sudo apt install ntpdate
sudo ntpdate ntp.ubuntu.com

After synchronizing time with correct current datetime, this issue will be resolved

@Ashutosh Jha 2018-06-11 09:31:27

I was also facing this issue , added

correctClockSkew: true

and issue fixed for me

const nodemailer = require('nodemailer');
const ses = require('nodemailer-ses-transport');



let transporter = nodemailer.createTransport(ses({
        correctClockSkew: true,
        accessKeyId: **,
        secretAccessKey: **,
        region: **
    }));

@Yeshodhan Kulkarni 2017-05-17 20:54:30

You need to synchronize your machines local clock with NTP.

for eg. on an ubuntu machine:

sudo ntpdate pool.ntp.org

System time goes out of sync quite often. You need to keep them in sync periodically.

You can run a daily CRON job to keep your system time in sync as mentioned at this link: Periodically synchronize time in Linux

Create a bash script to sync time called ntpdate and put the below into it

#!/bin/sh
# sync server time
/usr/sbin/ntpdate pool.ntp.org >> /tmp/ntpdate.log

You can place this script anywhere you like and then set up a cron I will be putting it into the daily cron directory so that it runs once every day So my ntpdate script is now in /etc/cron.daily/ntpdate and it will run every day

Make this script executable

chmod +x /etc/cron.daily/ntpdate

Test it by running the script once and look for some output in /tmp/ntpdate.log

/etc/cron.daily/ntpdate

In your log file you should see something like

26 Aug 12:19:06 ntpdate[2191]: adjust time server 206.108.0.131 offset 0.272120 sec

@j10 2017-05-19 04:42:18

Thanks for sharing that @Yeshodhan. a guess - I have set my MacBook's time to Auto Set Date and Time - I believe this will take care of synchronization ?

@Akshay Agarwal 2019-02-27 05:19:32

This is very likely to happen if you are on a VM, especially using Vagrant and if you leverage the suspend command frequently. Just a note from personal experience.

@MikeD at AWS 2017-05-17 19:57:15

A request signed with AWS sigV4 includes a timestamp for when the signature was created. Signatures are only valid for a short amount of time after they are created. (This limits the amount of time that a replay attack can be attempted.)

When the signature is validated the timestamp is compared to the current time. If this indicates that the signature was not created recently, then signature validation fails with the error message you mentioned.

A common cause of this is when the local clock on the host generating the signature is off by more than a couple of minutes.

Related Questions

Sponsored Content

2 Answered Questions

[SOLVED] AWS Lambda gateway API gives error message

1 Answered Questions

[SOLVED] Invoking AWS Lambda endpoint

0 Answered Questions

Can not use GET and POST function to AWS API gateway with HTTP proxy

0 Answered Questions

Postman call to get S3 Bucket Location Fails for regions other than "us-east-1"

  • 2018-07-03 12:48:23
  • aravindp03
  • 126 View
  • 1 Score
  • 0 Answer
  • Tags:   amazon-s3 postman

1 Answered Questions

1 Answered Questions

2 Answered Questions

[SOLVED] AWS API Gateway Javascript SDK Returns 404 Not Found

  • 2015-11-26 05:18:13
  • rjobidon
  • 450 View
  • 0 Score
  • 2 Answer
  • Tags:   aws-api-gateway

Sponsored Content