-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add automatic support for p11-kit #260
Changes from 1 commit
2723a8f
237a370
1e80f66
bc3ba29
a23378d
f840799
8d82ef2
572bfb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,18 @@ func TestNew(t *testing.T) { | |
return k.p11, nil | ||
} | ||
|
||
var ( | ||
wantMissingModule *PKCS11 | ||
wantErrMissingModule = true | ||
) | ||
if findP11KitProxy(context.Background()) != "" { | ||
wantMissingModule = k | ||
wantErrMissingModule = false | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be a more accurate test if the output of the shell command were mocked instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed with 237a370 |
||
|
||
canceledContext, cancel := context.WithCancel(context.Background()) | ||
cancel() | ||
|
||
type args struct { | ||
ctx context.Context | ||
opts apiv1.Options | ||
|
@@ -68,10 +80,14 @@ func TestNew(t *testing.T) { | |
URI: "pkcs11:module-path=/usr/local/lib/softhsm/libsofthsm2.so;token=pkcs11-test", | ||
Pin: "passowrd", | ||
}}, k, false}, | ||
{"fail missing module", args{context.Background(), apiv1.Options{ | ||
{"perhaps with missing module", args{context.Background(), apiv1.Options{ | ||
Type: "pkcs11", | ||
URI: "pkcs11:token=pkcs11-test", | ||
Pin: "passowrd", | ||
}}, wantMissingModule, wantErrMissingModule}, | ||
{"fail findP11KitProxy", args{canceledContext, apiv1.Options{ | ||
Type: "pkcs11", | ||
URI: "pkcs11:token=pkcs11-test?pin-value=password", | ||
}}, nil, true}, | ||
{"fail missing pin", args{context.Background(), apiv1.Options{ | ||
Type: "pkcs11", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in the wrong place, isn't it? It'll only happen if a URI is given, but there's an alternative code flow where it's all in the config? That should benefit from the default, too.
There's already a check for
config.Path == ""
a few lines further down, with an error return which is no longer telling the truth because it says that 'module-path is required'.Also... what's wrong with
pkcs11:manufacturer=piv_II;id=%01
which I usually use as my examples in documentation? Why are only token/serial/slot-id accepted, and not model/manufacturer?(And why is this something you even need to do for yourself; surely "match token against the attributes in a URI" is a generic thing that ought to be somewhere much further down the stack than your code; in ThalesIgnite/crypto11 or miekg/pkcs11. Ideally you just want to call a function like the matchSlots() I wrote here, and in your case as discussed, you want to just bail if
len(slots) != 1
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In particular, these two:
.. especially the former. I don't want to live in a world where we have to tell users to explicitly pass a
module-path
.All those examples for how to use different HSMs differ mostly in the
module-path
, which shouldn't be needed anyway.The packaging of the PKCS#11 provider module itself should come with a p11-kit .module file, the token should automatically appear in the output of things like
p11-kit list-tokens
orp11tool --list-tokens
(and thus also in GUIs when you're selecting a client cert for 802.1x or VPN auth, etc.)The common case is that user should just be able to select a token from the list, e.g.
pkcs11:manufacturer=piv_II
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PKCS#11 cannot be configured without a URI, currently you will get the following error:
We can make it more explicit and actually fail if URI == "".
Nothing, but https://github.com/ThalesIgnite/crypto11, which is the one we use on top of github.com/miekg/pkcs11 doesn't support it, see this code.
Regarding the documentation, some of it is managed by a different team, and we haven't integrated this yet, so it will have to wait a bit. But I can change
step-kms-plugin
README and help once this is integrated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed some of this in a23378d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I've added that specific reference to ThalesGroup/crypto11#104