Skip to content

Expose configuration to set maximum number of PKCS#11 sessions#52768

Merged
rosstimothy merged 1 commit intomasterfrom
tross/pkcs11_max_sessions
Mar 6, 2025
Merged

Expose configuration to set maximum number of PKCS#11 sessions#52768
rosstimothy merged 1 commit intomasterfrom
tross/pkcs11_max_sessions

Conversation

@rosstimothy
Copy link
Copy Markdown
Contributor

@rosstimothy rosstimothy commented Mar 4, 2025

The PKCS#11 library that we use defaults to allowing 1024 concurrent sessions. If an HSM is configured with a lower limit it results in broken UX since the PKCS#11 library does not reuse open and available sessions until it has opened the maximum number of sessions that it can. While the library behavior is out of our control, we now allow users the ability to specify what their desired max and propagate it on to the PKCS#11 library so that it will not open more sessions than the HSM will allow.

The auth config reference was updated to include ca_key_params. While these config options were somewhat discoverable via individual HSM guides, they were not mentioned in the auth reference.

changelog: Allow specifying the maximum number of PKCS#11 HSM connections.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 4, 2025

Amplify deployment status

Branch Commit Job ID Status Preview Updated (UTC)
tross/pkcs11_max_sessions 5547855 6 ✅SUCCEED tross-pkcs11-max-sessions 2025-03-05 14:22:22

@rosstimothy rosstimothy force-pushed the tross/pkcs11_max_sessions branch from 2e864bd to 8a43abd Compare March 4, 2025 20:30
@rosstimothy rosstimothy requested a review from nklaassen March 4, 2025 20:53
@rosstimothy rosstimothy marked this pull request as ready for review March 4, 2025 20:53
@github-actions github-actions bot requested a review from hugoShaka March 4, 2025 20:54
return trace.BadParameter("must provide one of SlotNumber or TokenLabel")
}

if cfg.MaxSessions == 1 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if cfg.MaxSessions == 1 {
if cfg.MaxSessions <= 1 {

It's a signed integer, so might as well protect against 0 or negative values too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PKCS11 library will accept zero and interprets it as use the default value. It will however reject a value of 1. If we want I can defer this entirely to the PKCS11 library, though I was trying to produce a more helpful error message by catching a value of 1 explicitly here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the library doesn't handle negative values though, so perhaps we want to handle negative values, zero, and one specifically here.

@rosstimothy rosstimothy force-pushed the tross/pkcs11_max_sessions branch from 8a43abd to 547d3de Compare March 4, 2025 21:30
@Tener Tener removed their request for review March 5, 2025 08:04
The PKCS#11 that we use defaults to allowing 1024 concurrent
sessions. If an HSM is configured with a lower limit it results in
broken UX since the PKCS#11 library does not reuse open and available
sessions until it has opened the maximum number of sessions that it
can. While the library behavior is out of our control, we now allow
users the ability to specify what their desired max and propagate it
on to the PKCS#11 library so that it will not open more sessions
than the HSM will allow.

The auth config reference was updated to include `ca_key_params`.
While these config options were somewhat discoverable via individual
HSM guides, they were not mentioned in the auth reference.
@rosstimothy rosstimothy force-pushed the tross/pkcs11_max_sessions branch from 78a95d4 to 5547855 Compare March 5, 2025 14:14
@rosstimothy rosstimothy requested a review from zmb3 March 6, 2025 14:32
@rosstimothy rosstimothy added this pull request to the merge queue Mar 6, 2025
Merged via the queue into master with commit 95c5184 Mar 6, 2025
44 checks passed
@rosstimothy rosstimothy deleted the tross/pkcs11_max_sessions branch March 6, 2025 18:22
@public-teleport-github-review-bot
Copy link
Copy Markdown

@rosstimothy See the table below for backport results.

Branch Result
branch/v15 Failed
branch/v16 Failed
branch/v17 Create PR

rosstimothy added a commit that referenced this pull request Mar 7, 2025
The PKCS#11 that we use defaults to allowing 1024 concurrent
sessions. If an HSM is configured with a lower limit it results in
broken UX since the PKCS#11 library does not reuse open and available
sessions until it has opened the maximum number of sessions that it
can. While the library behavior is out of our control, we now allow
users the ability to specify what their desired max and propagate it
on to the PKCS#11 library so that it will not open more sessions
than the HSM will allow.

The auth config reference was updated to include `ca_key_params`.
While these config options were somewhat discoverable via individual
HSM guides, they were not mentioned in the auth reference.
github-merge-queue bot pushed a commit that referenced this pull request Mar 7, 2025
… (#52880)

The PKCS#11 that we use defaults to allowing 1024 concurrent
sessions. If an HSM is configured with a lower limit it results in
broken UX since the PKCS#11 library does not reuse open and available
sessions until it has opened the maximum number of sessions that it
can. While the library behavior is out of our control, we now allow
users the ability to specify what their desired max and propagate it
on to the PKCS#11 library so that it will not open more sessions
than the HSM will allow.

The auth config reference was updated to include `ca_key_params`.
While these config options were somewhat discoverable via individual
HSM guides, they were not mentioned in the auth reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants