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:
- Replay Attacks: Attackers intercept requests and send them repeatedly.
- Request Forgery: Forging requests using expired or future timestamps.
- 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:
- Open "Settings" → "General" → "Date & Time".
- Turn on "Set Automatically".
Android Devices:
- Open "Settings" → "System" → "Date & time".
- Turn on "Use network-provided time".
Windows:
- Right-click the time on the taskbar → "Adjust date/time".
- Turn on "Set time automatically".
macOS:
- Open "System Preferences" → "Date & Time".
- 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:
- Do not rely on local time: Use server time in your business logic.
- Prompt the user: When a large time deviation is detected, guide the user to calibrate their system time.
- 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
- What should I do if CloudBase is unavailable after changing my phone time?
- How do I resolve Cloud Storage access failures caused by incorrect system time?
- What is the cause of signature expired prompts in CloudBase?
- Why can't I access the database after modifying the system time?
- How do I handle "request time too skewed" errors?
- What is the timestamp verification mechanism of CloudBase?
- How do I resolve cloud resource access issues caused by unsynchronized time?
- What should I do if CloudBase time verification fails in WeChat Mini Program?
- How much system time deviation will affect CloudBase?
- What does the CloudBase security mechanism check?