Skip to content

Conversation

Bravo555
Copy link
Member

@Bravo555 Bravo555 commented Jun 26, 2025

TODO

  • handle all supported keys (EC 256/384, RSA 2048/3072/4096)
  • allow selecting token, key label, key type and size using command line arguments
  • write a test to maintain compatibility with 1.5.1
  • figure out why p11tool sometimes doesn't print curve ids of EC keys added to module documentation
  • see if we can remove added dependencies
  • generate URI for the new key so the user can replace the entire URI instead of tweaking parts
  • don't generate CSR in create-key, do it in tedge cert download
  • cleanup

Follow-up

  • show more information after key is created
  • test failure modes

Proposed changes

Implements a tedge cert create-key command that can be used to create a private key on a PKCS11 token without additional tools.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

#3665

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s. You can activate automatic signing by running just prepare-dev once)
  • I ran just format as mentioned in CODING_GUIDELINES
  • I used just check as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@Bravo555 Bravo555 had a problem deploying to Test Pull Request June 26, 2025 08:58 — with GitHub Actions Failure
@Bravo555 Bravo555 self-assigned this Jun 26, 2025
@Bravo555 Bravo555 force-pushed the feat/pkcs11-create-key branch from 7d44718 to c2e2aa1 Compare June 27, 2025 07:55
@Bravo555 Bravo555 had a problem deploying to Test Pull Request June 27, 2025 07:56 — with GitHub Actions Failure
@Bravo555 Bravo555 force-pushed the feat/pkcs11-create-key branch from c2e2aa1 to 993fd82 Compare June 27, 2025 17:57
@Bravo555 Bravo555 had a problem deploying to Test Pull Request June 27, 2025 17:57 — with GitHub Actions Failure
@Bravo555 Bravo555 force-pushed the feat/pkcs11-create-key branch from 993fd82 to 64f3a6b Compare June 30, 2025 17:06
@Bravo555 Bravo555 had a problem deploying to Test Pull Request June 30, 2025 17:06 — with GitHub Actions Failure
@reubenmiller reubenmiller added the theme:hsm Hardware Security Module related topics label Jul 3, 2025
@Bravo555 Bravo555 force-pushed the feat/pkcs11-create-key branch from 64f3a6b to 525651b Compare July 4, 2025 13:10
@Bravo555 Bravo555 had a problem deploying to Test Pull Request July 4, 2025 13:10 — with GitHub Actions Failure
@Bravo555 Bravo555 temporarily deployed to Test Pull Request July 9, 2025 16:23 — with GitHub Actions Inactive
@Bravo555 Bravo555 force-pushed the feat/pkcs11-create-key branch from 3025528 to c638b40 Compare July 10, 2025 07:52
@Bravo555 Bravo555 temporarily deployed to Test Pull Request July 10, 2025 07:52 — with GitHub Actions Inactive
Copy link
Contributor

github-actions bot commented Jul 10, 2025

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
670 0 3 670 100 1h48m51.053583999s

@Bravo555 Bravo555 force-pushed the feat/pkcs11-create-key branch from c638b40 to c3959cd Compare July 11, 2025 08:49
@Bravo555 Bravo555 temporarily deployed to Test Pull Request July 11, 2025 08:49 — with GitHub Actions Inactive
@Bravo555 Bravo555 force-pushed the feat/pkcs11-create-key branch from c3959cd to e099533 Compare July 14, 2025 14:31
@Bravo555 Bravo555 temporarily deployed to Test Pull Request July 14, 2025 14:31 — with GitHub Actions Inactive
@Bravo555 Bravo555 force-pushed the feat/pkcs11-create-key branch from e099533 to fef773e Compare July 14, 2025 14:36
@Bravo555 Bravo555 temporarily deployed to Test Pull Request July 14, 2025 14:36 — with GitHub Actions Inactive
@Bravo555 Bravo555 had a problem deploying to Test Pull Request July 14, 2025 15:13 — with GitHub Actions Failure
@Bravo555 Bravo555 force-pushed the feat/pkcs11-create-key branch from 25fe73f to 629ccbe Compare July 14, 2025 15:16
@Bravo555 Bravo555 temporarily deployed to Test Pull Request July 14, 2025 15:16 — with GitHub Actions Inactive
@Bravo555 Bravo555 force-pushed the feat/pkcs11-create-key branch from 0b2fc72 to 04abd57 Compare July 31, 2025 13:43
@Bravo555 Bravo555 temporarily deployed to Test Pull Request July 31, 2025 13:43 — with GitHub Actions Inactive
@Bravo555 Bravo555 force-pushed the feat/pkcs11-create-key branch from 04abd57 to 2ea7d45 Compare July 31, 2025 17:12
@Bravo555 Bravo555 had a problem deploying to Test Pull Request July 31, 2025 17:12 — with GitHub Actions Failure
Bravo555 added 20 commits August 8, 2025 08:05
The command uses TedgeP11Client to create a new RSA keypair on the
PKCS11 token.

Signed-off-by: Marcel Guzik <[email protected]>
Signed-off-by: Marcel Guzik <[email protected]>
Added options to create EC keys, however there remains a problem that
p11tool doesn't display curve names as it does with keys generated with
`p11tool --generate-privkey`.

Signed-off-by: Marcel Guzik <[email protected]>
Signed-off-by: Marcel Guzik <[email protected]>
Signed-off-by: Marcel Guzik <[email protected]>
Signed-off-by: Marcel Guzik <[email protected]>
Signed-off-by: Marcel Guzik <[email protected]>
Signed-off-by: Marcel Guzik <[email protected]>
Signed-off-by: Marcel Guzik <[email protected]>
This PR removes a limitation for generating CSRs using PKCS11 private
keys that they can only be generated for the same certificate that is
already present.

This unlocks two usecases that were previously impossible:
- using `tedge cert renew` to install a new certificate when we already
  have a certificate but a different keypair is used (previously
  SubjectPublicKeyInfo was reused from previous cert so using different
  key didn't work)
- using `tedge cert download c8y` when we don't yet have a certificate
  and register the device to C8y CA and download the initial certificate
  (previously some fields of CSR were reused from older cert so had no
  way to fill these fields without some certificate already being
  present)

Signed-off-by: Marcel Guzik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:hsm Hardware Security Module related topics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tedge cert create should support creating a key via the tedge-p11-server
2 participants