use freetsa::prelude::*;
use hex_literal::hex;
use std::{fs::OpenOptions, io::Write};
#[tokio::main]
async fn main() {
let my_hash: Vec<u8> = hex!("8d3fffddf79e9a232ffd19f9ccaa4d6b37a6a243dbe0f23137b108a043d9da13121a9b505c804956b22e93c7f93969f4a7ba8ddea45bf4aab0bebc8f814e0991").into();
let TimestampResponse { query, reply } = timestamp_hash(my_hash).await.unwrap();
let mut query_file = OpenOptions::new()
.create(true)
.write(true)
.open("./example.tsq")
.unwrap();
let mut reply_file = OpenOptions::new()
.create(true)
.write(true)
.open("./example.tsr")
.unwrap();
query_file.write_all(&query).unwrap();
reply_file.write_all(&reply).unwrap();
query_file.flush().unwrap();
reply_file.flush().unwrap();
println!("Download cacert.pem and tsa.crt from https://freetsa.org, then");
println!("run `openssl ts -verify -in example.tsr -queryfile example.tsq -CAfile cacert.pem -untrusted tsa.crt`");
}