Skip to main content

Cannot Access Cloud Resources After Modifying System Time

When using CloudBase, if a user modifies the system time of their mobile phone or computer, it may cause failures in accessing cloud resources such as Cloud Storage and Cloud Database.

Symptoms​

After modifying the local system time of the device, the following issues occur when accessing CloudBase resources:

  • Cloud Storage files cannot be downloaded or uploaded
  • Database queries return errors
  • Cloud Function calls fail
  • The console prompts signature errors or expired requests

Error messages may include:

signature expired
request time too skewed
invalid timestamp

Causes​

This is a security mechanism of cloud services. The server checks whether the timestamp in the request is within a reasonable range to prevent the following security risks:

  1. Replay Attacks: Attackers intercept requests and send them repeatedly.
  2. Request Forgery: Forging requests using expired or future timestamps.
  3. Signature Bypass: Modifying timestamps to bypass signature verification.

Generally, the server allows a time deviation of within 5–15 minutes. If the difference between the client time and the server time is too large, the request will be rejected.

Solutions​

Option 1: Restore the correct system time​

Restore the device's system time to the correct network time:

iOS Devices:

  1. Open "Settings" → "General" → "Date & Time".
  2. Turn on "Set Automatically".

Android Devices:

  1. Open "Settings" → "System" → "Date & time".
  2. Turn on "Use network-provided time".

Windows:

  1. Right-click the time on the taskbar → "Adjust date/time".
  2. Turn on "Set time automatically".

macOS:

  1. Open "System Preferences" → "Date & Time".
  2. Check "Set date and time automatically".

Option 2: Manually synchronize network time​

If automatic synchronization is unavailable, you can visit websites like time.is to obtain the accurate time and set it manually.

Developer Considerations​

If your application needs to run in a special time environment (e.g., testing scenarios), please note:

  1. Do not rely on local time: Use server time in your business logic.
  2. Prompt the user: When a large time deviation is detected, guide the user to calibrate their system time.
  3. Error handling: Capture time-related errors and provide friendly prompts.
// Example of detecting time skew
async function checkTimeSkew() {
try {
const serverTime = await getServerTime() // Get time from server
const localTime = Date.now()
const skew = Math.abs(serverTime - localTime)

if (skew > 5 * 60 * 1000) { // Deviation exceeds 5 minutes
console.warn('The system time deviates too much from the server time. Please calibrate the system time.')
}
} catch (err) {
console.error('Time verification failed', err)
}
}

FAQ​

  1. What should I do if CloudBase is unavailable after changing my phone time?
  2. How do I resolve Cloud Storage access failures caused by incorrect system time?
  3. What is the cause of signature expired prompts in CloudBase?
  4. Why can't I access the database after modifying the system time?
  5. How do I handle "request time too skewed" errors?
  6. What is the timestamp verification mechanism of CloudBase?
  7. How do I resolve cloud resource access issues caused by unsynchronized time?
  8. What should I do if CloudBase time verification fails in WeChat Mini Program?
  9. How much system time deviation will affect CloudBase?
  10. What does the CloudBase security mechanism check?