-use failure::*;
+use anyhow::{bail, format_err, Error};
use lazy_static::lazy_static;
use openssl::rsa::{Rsa};
use std::path::PathBuf;
-use proxmox::tools::{
- try_block,
- fs::{file_get_contents, replace_file, CreateOptions},
-};
+use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
+use proxmox::try_block;
+
+use crate::tools::epoch_now_u64;
fn compute_csrf_secret_digest(
timestamp: i64,
username: &str,
) -> String {
- let epoch = std::time::SystemTime::now().duration_since(
- std::time::SystemTime::UNIX_EPOCH).unwrap().as_secs() as i64;
+ let epoch = epoch_now_u64().unwrap() as i64;
let digest = compute_csrf_secret_digest(epoch, secret, username);
bail!("invalid signature.");
}
- let now = std::time::SystemTime::now().duration_since(
- std::time::SystemTime::UNIX_EPOCH)?.as_secs() as i64;
+ let now = epoch_now_u64()? as i64;
let age = now - ttime;
if age < min_age {