feat: Key selection using PKCS #11 URI#3555
Conversation
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
7bc11af to
f4c3112
Compare
f4c3112 to
8289373
Compare
48642ad to
45e9005
Compare
Robot Results
|
f104020 to
fb8699d
Compare
fb8699d to
e720092
Compare
didier-wenzek
left a comment
There was a problem hiding this comment.
I will be happy to approve. There are small points still to address though.
| # create tokens with no keys on them, so key selection fails if wrong token is selected | ||
| Execute Command softhsm2-util --init-token --free --label token2 --pin "123456" --so-pin "123456" | ||
| Execute Command softhsm2-util --init-token --free --label token3 --pin "123456" --so-pin "123456" | ||
| Execute Command softhsm2-util --init-token --free --label token4 --pin "123456" --so-pin "123456" | ||
| Execute Command softhsm2-util --init-token --free --label token5 --pin "123456" --so-pin "123456" | ||
| Execute Command softhsm2-util --init-token --free --label token6 --pin "123456" --so-pin "123456" |
There was a problem hiding this comment.
I don't get the point of these fake tokens. The tests pass without those.
There was a problem hiding this comment.
removed in a8a732e.
This is a leftover I forgot to remove from the previous approach which I abandoned because it was bad. Currently when there are many keys, we just use the first one returned to us by the PKCS#11 implementation. The idea was to create many new tokens, such that one of them would be picked up as "first" and used and later return an error because it does not contain a key.
But relying on an arbitrary implementation-specific order is bad. In situations where there are many tokens/keys to be used and we can't automatically select a good one, we should fail right there and require a user to provide a URI that uniquely identifies a key to be used.
So the test was changed to explicitly point to a token without the key and then to a token with the correct key. As for actually returning an error where a key cannot be uniquely identified, it will be implemented in the next commit.
EDIT: On a today's daily call it was deemed that a warning will be sufficient.
b3f22a9 to
142fad5
Compare
142fad5 to
3ffd1f9
Compare
9ce4a3a to
e878e08
Compare
There was a problem hiding this comment.
Approved
Edited. A system test was failing for a silly error. Fixed: 4141e33
Signed-off-by: Marcel Guzik <marcel.guzik@cumulocity.com>
Signed-off-by: Marcel Guzik <marcel.guzik@cumulocity.com>
4141e33 to
def1922
Compare
TODO
requirewarn a userto provide a URI that uniquely identifies key to useif there are multiple tokens/keys and URI is either not provided or not sufficiently precise (feat: Key selection using PKCS #11 URI #3555 (comment))Follow-up
Proposed changes
Allows the user to denote private key that will be used by
tedge-p11-serverfor signing by a new optional--uriparameter.The PKCS #11 URI is explained in RFC 7512. It can be used to identify any cryptoki resource by its properties. In our case it's used to select a key, but the URI given by the user doesn't have to identify a key, but can identify e.g a token which we can select and
find its firstif the token contains only one private key, use that key.Types of changes
Paste Link to the issue
Checklist
just prepare-devonce)just formatas mentioned in CODING_GUIDELINESjust checkas mentioned in CODING_GUIDELINESFurther comments