Skip to content

openssl: fix pkcs11 provider available check #17804

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

Closed

Conversation

piotr-nakraszewicz-red
Copy link
Contributor

Commit f2ce6c4 among other things added the use of own library context instead of the default context. Default context has access to OpenSSL configuration file, own context doesn't have it.
Therefore if a pkcs11 provider is loaded via config file, the function OSSL_PROVIDER_available() incorrectly detects the provider as unavailable.

Fix this by loading the OpenSSL config to the library context according to OpenSSL documentation:
"OSSL_LIB_CTX_load_config() loads a configuration file using the given ctx. This can be used to associate a library context with providers that are loaded from a configuration."

Moreover use the provider_loaded flag instead of provider pointer to determine if a provider is available, as the latter is not set when the provider is loaded from a configuration.

@github-actions github-actions bot added the TLS label Jul 2, 2025
@testclutch
Copy link

Analysis of PR #17804 at 029ad30e:

Test 358 failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 6 different CI jobs (the link just goes to one of them).

Generated by Testclutch

Commit f2ce6c4 among other things added the use of own library context
instead of the default context. Default context has access to OpenSSL
configuration file, own context doesn't have it.
Therefore if a pkcs11 provider is loaded via config file, the function
OSSL_PROVIDER_available() incorrectly detects the provider as
unavailable.

Fix this by loading the OpenSSL config to the library context according
to OpenSSL documentation:
"OSSL_LIB_CTX_load_config() loads a configuration file using the given
ctx. This can be used to associate a library context with providers that
are loaded from a configuration."

Moreover use the provider_loaded flag instead of provider pointer to
determine if a provider is available, as the latter is not set when the
provider is loaded from a configuration.
Copy link
Member

@vszakats vszakats left a comment

Choose a reason for hiding this comment

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

Thanks for the update, it addresses my concern.

I suggest requesting a review from @bagder for a second look.

@piotr-nakraszewicz-red
Copy link
Contributor Author

Thank you again @vszakats for your review.
I don't seem to have rights to add reviewers myself. @bagder could you please review as suggested by @vszakats ?

@vszakats vszakats requested a review from bagder July 3, 2025 21:45
@bagder bagder closed this in e022da0 Jul 4, 2025
@bagder
Copy link
Member

bagder commented Jul 4, 2025

Thanks!

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

Successfully merging this pull request may close these issues.

4 participants