From f936852861662b235287cd274c96f7e9779690cd Mon Sep 17 00:00:00 2001 From: Eric Swanson <64809312+ericswanson-dfinity@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:25:45 -0800 Subject: [PATCH] fix: for canister delete with HSM trying to open two sessions (#3517) A HardwareIdentity holds a session open to the HSM. This means an attempt to create a second HardwareIdentity to the same HSM will fail. `dfx canister delete` tried to do this, though it didn't need to. Fixes https://dfinity.atlassian.net/browse/SDK-1346 --- CHANGELOG.md | 4 ++++ src/dfx/src/commands/canister/delete.rs | 4 +--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d331f095b..e53ea15613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,10 @@ Updated to candid 0.10, ic-cdk 0.12, and ic-cdk-timers 0.6 They've always been stored with nanosecond precisions on Linux and Macos. Now they are stored with nanosecond precision on Windows too. +### fix: dfx canister delete, when using an HSM identity, no longer fails by trying to open two sessions to the HSM + +Previously, this would fail with a PKCS#11: CKR_CRYPTOKI_ALREADY_INITIALIZED error. + ## Dependencies ### Motoko diff --git a/src/dfx/src/commands/canister/delete.rs b/src/dfx/src/commands/canister/delete.rs index 3cd04a9faa..877d316ae6 100644 --- a/src/dfx/src/commands/canister/delete.rs +++ b/src/dfx/src/commands/canister/delete.rs @@ -1,4 +1,3 @@ -use crate::lib::agent::create_agent_environment; use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::ic_attributes::CanisterSettings; @@ -129,8 +128,7 @@ async fn delete_canister( }, CallSender::SelectedId => { let network = env.get_network_descriptor(); - let agent_env = create_agent_environment(env, Some(network.name.clone()))?; - let identity_name = agent_env + let identity_name = env .get_selected_identity() .expect("No selected identity.") .to_string();