Skip to content

Commit

Permalink
Prevent empty iv or private key
Browse files Browse the repository at this point in the history
  • Loading branch information
Clint.Network committed Mar 1, 2020
1 parent e6788a2 commit cc829dc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,18 @@ impl Server {

let mut encryption_key = None;
if configuration.encryption.enabled {
encryption_key = Some([
configuration.encryption.private_key.as_str(),
configuration.encryption.iv.as_str(),
]);
if configuration.encryption.private_key.is_empty() {
panic!("The private key must be filled.");
}
else if configuration.encryption.iv.is_empty() {
panic!("The initialization vector must be filled.")
}
else {
encryption_key = Some([
configuration.encryption.private_key.as_str(),
configuration.encryption.iv.as_str(),
]);
}
}
let store = Arc::new(KvStore::new(encryption_key));
let store = warp::any().map(move || store.clone());
Expand Down

0 comments on commit cc829dc

Please sign in to comment.