Skip to content

Commit 79f0eb4

Browse files
committed
trim private key
1 parent 94ae514 commit 79f0eb4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

db_v2.sqlite3

0 Bytes
Binary file not shown.

src/common.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,17 @@ pub fn gen_sk(wait: u64) -> (String, Option<sign::SecretKey>) {
113113
if let Ok(mut file) = std::fs::File::open(sk_file) {
114114
let mut contents = String::new();
115115
if file.read_to_string(&mut contents).is_ok() {
116-
let sk = base64::decode(&contents).unwrap_or_default();
116+
let contents = contents.trim();
117+
let sk = base64::decode(contents).unwrap_or_default();
117118
if sk.len() == sign::SECRETKEYBYTES {
118119
let mut tmp = [0u8; sign::SECRETKEYBYTES];
119120
tmp[..].copy_from_slice(&sk);
120121
let pk = base64::encode(&tmp[sign::SECRETKEYBYTES / 2..]);
121122
log::info!("Private key comes from {}", sk_file);
122123
return (pk, Some(sign::SecretKey(tmp)));
123124
} else {
124-
log::error!("Malformed private key. You probably have a trailing newline in the secret key file.");
125+
// don't use log here, since it is async
126+
println!("Fatal error: malformed private key in {sk_file}.");
125127
std::process::exit(1);
126128
}
127129
}

0 commit comments

Comments
 (0)