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

Add finding certificate chain #83

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

al1img
Copy link

@al1img al1img commented Jun 16, 2021

This PR adds functionality to retrieve the certificate chain with FindCertificateChain function. This function has the same format as the existing FindCertificate function. The search of the first certificate is done by id, label, or serial, similar to FindCertificate function. The search of the rest certificates is done by issuer - subject path. If the corresponding certificate is not found by the subject, it tries to find it by authority - subject key id path.

@ProsaicSatsuma
Copy link
Contributor

Thanks for the PR Oleksandr. Currently in review and will get back to you shortly

@al1img al1img force-pushed the find_certificate_chain branch 6 times, most recently from c72fb44 to 41395d0 Compare February 4, 2022 09:11
Current private certificate functions implement limited functionality to
find x509 certificate by id and/or label and/or serial. They can't be
reused to implement more generic find certificates API.

This commit contains following changes:

* implement generic findCertificatesWithAttributes function which allows
  to find certificates by defined templates. This function returns slice
  of pkcs11.ObjectHandle. Handles can be used to retrieve any information
  from pkcs11 object;
* reimplement findCertificate function to use generic certificate
  functions.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Certificate chain is found by following algorithm:

* find first certificate either by id or/and label or/and serial (same as
  existing FindCertificate does);
* if issuer is not nil, find next certificate by CKA_SUBJECT (issuer should
  be equal subject);
* if certificate with required subject not found then read all certificates
  and try to find next certificate by AuthorityKeyId (AuthorityKeyId should
  be equal to SubjectKeyId);
* finding stops if last found certificate is selfsigned (issuer is nil or
  equals to subject).

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
@al1img
Copy link
Author

al1img commented Feb 4, 2022

I've created the issue #91 that describes the problem I would like to solve with this PR. Probably there is a better solution.

Add methods to find and delete certificates with custom attributes.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
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.

2 participants