Skip to content

Commit 7be36f0

Browse files
authored
Merge pull request #703 from Nitrokey/nethsm-shutdown-unprovisioned
Add support for unauthenticated NetHSM shutdown
2 parents 1b5d75a + 917bcf3 commit 7be36f0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pynitrokey/cli/nethsm.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,13 @@ def shutdown(ctx: Context, force: bool) -> None:
16671667
16681668
This command requires authentication as a user with the Administrator
16691669
role."""
1670-
with connect(ctx) as nethsm:
1670+
require_auth = False
1671+
with connect(ctx, require_auth=require_auth) as nethsm:
1672+
state = nethsm.get_state()
1673+
if state == State.OPERATIONAL:
1674+
require_auth = True
1675+
1676+
with connect(ctx, require_auth=require_auth) as nethsm:
16711677
print(f"NetHSM {nethsm.host} will be shutdown.")
16721678
shutdown = force or click.confirm("Do you want to continue?")
16731679

0 commit comments

Comments
 (0)