I'm working with some cached Pre-Signed URLs for S3 downloads, pretty simple. We have many URLs for each asset and many assets for each request, then to avoid generating so many new Pre-Signed URLs per request we are saving the Pre-Signed URLs while the expiration is far from happening. It works fine most of time but from time to time we receive a 400 Bad Request with "Token expired" error message.
For what I learned:
- S3 Pre-Signed URLs also carry accessKeyId which is the authentication of the signer.
- The signer key also has its own expiration time.
- The Pre-Signed URL can be rejected if the Signer key has expired even if the expiration of the URL itself is not reached.
So the question I have is: how can I check the expiration time of an accessKeyId since my Server can already refreshed its own key (and add to this the uncertainty of Server instances different or not keys) and I no longer have access to AWS.config.credentials.expirationTime
?