Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions cryptoki/src/session/session_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
//! Session management functions

use crate::context::Function;
use crate::error::{Result, Rv};
use crate::error::{Error, Result, Rv, RvError};
use crate::session::{Session, SessionInfo, UserType};
use crate::types::{AuthPin, RawAuthPin};

#[cfg(doc)]
use cryptoki_sys::CKF_PROTECTED_AUTHENTICATION_PATH;
use cryptoki_sys::CK_SESSION_INFO;
use log::error;
use log::{error, warn};
use secrecy::ExposeSecret;
use std::convert::{TryFrom, TryInto};

Expand All @@ -27,7 +27,12 @@ impl Drop for Session {
}

if let Err(err) = close(self) {
error!("Failed to close session: {err}");
match err {
Error::Pkcs11(RvError::SessionHandleInvalid, _) => {
warn!("Failed to close session: The specified session handle is invalid, the session must be already closed.");
}
_ => error!("Failed to close session: {err}"),
}
}
}
}
Expand Down
Loading