Skip to content

Commit

Permalink
Fix spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackDex committed Jul 17, 2024
1 parent 5c1dec9 commit 5fbeaae
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ static PRIVATE_RSA_KEY: OnceCell<EncodingKey> = OnceCell::new();
static PUBLIC_RSA_KEY: OnceCell<DecodingKey> = OnceCell::new();

pub fn initialize_keys() -> Result<(), crate::error::Error> {
fn read_key(creat_if_missing: bool) -> Result<(Rsa<openssl::pkey::Private>, Vec<u8>), crate::error::Error> {
fn read_key(create_if_missing: bool) -> Result<(Rsa<openssl::pkey::Private>, Vec<u8>), crate::error::Error> {
let mut priv_key_buffer = Vec::with_capacity(2048);

let mut priv_key_file = File::options()
.create(creat_if_missing)
.create(create_if_missing)
.truncate(false)
.read(true)
.write(creat_if_missing)
.write(create_if_missing)
.open(CONFIG.private_rsa_key())?;

#[allow(clippy::verbose_file_reads)]
let bytes_read = priv_key_file.read_to_end(&mut priv_key_buffer)?;

let rsa_key = if bytes_read > 0 {
Rsa::private_key_from_pem(&priv_key_buffer[..bytes_read])?
} else if creat_if_missing {
} else if create_if_missing {
// Only create the key if the file doesn't exist or is empty
let rsa_key = openssl::rsa::Rsa::generate(2048)?;
priv_key_buffer = rsa_key.private_key_to_pem()?;
Expand Down

0 comments on commit 5fbeaae

Please sign in to comment.