Skip to content
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

Support import certificate using softhsm2-util #612

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

alonbl
Copy link
Contributor

@alonbl alonbl commented Feb 21, 2021

The softhsm2-util already support importing keys, why not also import
certificates?

Useful for test scripts that require both keys and certificates.

Add --import-type parameter, depreciate the --aes parameter.

Signed-off-by: Alon Bar-Lev alon.barlev@gmail.com

@rijswijk
Copy link
Contributor

Thank you for your contribution, I have some things to consider before merging:

Certificate import may be slightly more complex, since certificates are often associated with keys. Different applications link
keys and certificates in different ways (e.g. one example might be to have matching CKA_ID attributes, but other options also exist). I'm not entirely sure whether adding this type of support to softhsm2-util is the right way forward, it might be too narrowly scoped to a particular use case.

@halderen your opinion would be welcome.

If we do decide to proceed with this, I think the following changes/features would be necessary:

  • Don't do an immediate deprecation of --import, instead, clearly mark it as deprecated in the documentation (usage, man page) and tag it for future removal (while you still support it, it is immediately deprecated without documentation)
  • Support Botan as well (to keep the two builds in sync)

@alonbl alonbl force-pushed the import-cert branch 2 times, most recently from b5aab9a to 547eaad Compare February 22, 2021 18:18
@alonbl
Copy link
Contributor Author

alonbl commented Feb 22, 2021

Hi,

Thank you for the review. I altered the implementation and added --import-type instead of deprecating the --import, I hope you like it better.

For the matching between key and certificate, as far as I know the best practice is to match the CKA_ID or read the entire token and match based on public key. The option to even having a basic import is significant for the use case of using the provider as test framework. If an application has special needs it can always perform the import by its own.

I have been around for years in PKCS#11 domain and never saw a setup in which the CKA_ID is not used for matching.

If you ACK I will update the man page and try to hack the botan as well.

Regards,
Alon

@alonbl alonbl changed the title softhsm2-util: add --import-cert softhsm2-util: support import certificate Feb 22, 2021
@alonbl
Copy link
Contributor Author

alonbl commented Feb 22, 2021

The botan part was actually simpler than I thought, so I applied the botan part and the man part.

@alonbl alonbl force-pushed the import-cert branch 3 times, most recently from 8876f7b to 53e6299 Compare February 22, 2021 20:04
@rijswijk
Copy link
Contributor

Thanks, looks good, one small request: the PR is still essentially deprecating the current mode of use of --import (which essentially assumes it's always a key pair unless --aes is specified). Furthermore, it looks like you removed the documentation for --aes from the manual page while the option is still silently supported. To really make it a "nice" deprecation, I suggest the following:

  • If --aes is specified, print a warning to stderr that says something like "Warning: use of --aes is deprecated, this flag will be removed in a future version"
  • If --import is specified without --import-type, print a warning to stderr that says something like "Warning: use of --import without specifying the object type with --import-type is deprecated, assuming "keypair"; future versions will give an error in this case."
  • Clear flag the deprecated behaviour in the manual page

Again, thanks for your contribution, I think with the changes above we'd be good to go for a review by @halderen and a merge.

@alonbl
Copy link
Contributor Author

alonbl commented Feb 23, 2021 via email

@rijswijk
Copy link
Contributor

I think I agree, I'm going to ask @halderen to review and merge. Thanks!

@rijswijk rijswijk requested a review from halderen February 24, 2021 07:43
@alonbl
Copy link
Contributor Author

alonbl commented Jul 31, 2021

ping?

@alonbl
Copy link
Contributor Author

alonbl commented Sep 7, 2021

Hi @halderen,
Can you please also checkout this one?
Thanks!

@davydsantos
Copy link

+1 on the feature. This can be accomplished by using opensc/pkcs11-tool but it would be easier to rely on one single tool for both tasks. Another possible feature could be to allow importing a p12/pfx directly without the need of breaking it up in 2 different files and it would handle everything internally.

@alonbl
Copy link
Contributor Author

alonbl commented Feb 6, 2022

Rebased.

Hi @halderen,
Can you please also checkout this one? I will be glad to accept any feedback.
Thanks!

@alonbl
Copy link
Contributor Author

alonbl commented Jul 29, 2022

Hi @halderen,
Do you have time to review this?
Thanks.

@alonbl
Copy link
Contributor Author

alonbl commented Oct 18, 2022

ping?
I see almost no activity in project, any chance to merge it? feature was acked and change was reviewed.
thanks!

@alonbl
Copy link
Contributor Author

alonbl commented Sep 11, 2023

Hello @halderen, can you please look at this patch? It would be great if we can use the softhsm2-util to import certificates for unit tests without additional software.

@tougantium
Copy link

@halderen: I would also appreciate this PR very much, could you please consider merging.

@alonbl
Copy link
Contributor Author

alonbl commented Oct 7, 2024

Rebased.

@halderen: can you please review? this is super handy utility for unittest of PKCS#11 enabled application.

@jschlyter jschlyter marked this pull request as draft November 29, 2024 16:23
@jschlyter
Copy link
Contributor

Please rebase on develop and mark as ready when ready.

@alonbl alonbl force-pushed the import-cert branch 2 times, most recently from e7e576d to cc9d83f Compare November 29, 2024 23:39
@alonbl alonbl marked this pull request as ready for review November 29, 2024 23:49
@alonbl alonbl requested a review from a team as a code owner November 29, 2024 23:49
@alonbl
Copy link
Contributor Author

alonbl commented Nov 29, 2024

Please rebase on develop and mark as ready when ready.

Hi @jschlyter,
Done :)
Thanks!

src/bin/util/softhsm2-util-botan.cpp Outdated Show resolved Hide resolved
src/bin/util/softhsm2-util-ossl.cpp Outdated Show resolved Hide resolved
Copy link
Contributor Author

@alonbl alonbl left a comment

Choose a reason for hiding this comment

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

Hello @ijsf ,

Thank you for reviewing.
I pushed a new revision, I hope it will address your concerns.

Regards,

src/bin/util/softhsm2-util-botan.cpp Outdated Show resolved Hide resolved
src/bin/util/softhsm2-util-ossl.cpp Outdated Show resolved Hide resolved
src/bin/util/softhsm2-util.cpp Outdated Show resolved Hide resolved
src/bin/util/softhsm2-util-botan.cpp Outdated Show resolved Hide resolved
@alonbl
Copy link
Contributor Author

alonbl commented Dec 13, 2024

Hello @jschlyter, is there anything more I can do to push this forward?

@jschlyter jschlyter changed the title softhsm2-util: support import certificate Support import certificate using softhsm2-util Dec 14, 2024
@jschlyter
Copy link
Contributor

I think we're good, but I'd appreciate if @bjosv could take a look as well.

Copy link
Contributor

@bjosv bjosv left a comment

Choose a reason for hiding this comment

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

Looks useful, just have a few comment before a merge.

src/bin/util/softhsm2-util-ossl.cpp Outdated Show resolved Hide resolved
src/bin/util/softhsm2-util-ossl.cpp Outdated Show resolved Hide resolved
src/bin/util/softhsm2-util-botan.cpp Outdated Show resolved Hide resolved
The softhsm2-util already support importing keys, why not also import
certificates?

Useful for test scripts that require both keys and certificates.

Add --import-type <type> parameter, depreciate the --aes parameter.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
@alonbl
Copy link
Contributor Author

alonbl commented Dec 16, 2024

@bjosv thank you for spotting this leftover!

I hope all is good now.

@jschlyter jschlyter requested a review from bjosv December 16, 2024 19:33
Copy link
Contributor

@bjosv bjosv left a comment

Choose a reason for hiding this comment

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

LGTM!

@jschlyter
Copy link
Contributor

One more thing @alonbl, could you add a test case for the import function in a separate PR?

@jschlyter jschlyter merged commit 0053e2b into softhsm:develop Dec 17, 2024
7 checks passed
@alonbl
Copy link
Contributor Author

alonbl commented Dec 17, 2024

Hello @jschlyter,

I do not see any test cases for the usage of the utilities.
I may miss this, if there is infrastructure for this, please refer me and I will add this specific test case.

Thanks,
Alon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants