-
Notifications
You must be signed in to change notification settings - Fork 45
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
Prevent multiple initializations #452
Comments
I'm not sure if it's a provider feature. Application should call |
Applications should be able to cretae different context and load the provider on each multiple times, though, so I think we need to do some checking |
|
loading in a context that already has the provider initialized is something probably openssl should bail on on its own, and will not be supported. But I am thinking of cases where the provider is loaded in multiple different contexts, I need to verify that is ok. |
Yes, the test is worth having |
Hm, libssh is using exactly this https://gitlab.com/libssh/libssh-mirror/-/blob/master/src/pki_crypto.c#L2785 and yet the provider ends up initialized multiple times. This code is called for each key specified by uri. I would assume that once provider is part of the openssl config (and activated there) then OSSL_PROVIDER_available(NULL, "pkcs11") returns true (hence libssh will nevert attempt to load it itself (cc @Jakuje, @sahanaprasad07). |
I see a much larger issue with libssh code, namely they are interfering with the default OpenSSL context. |
I think we do not have a separate openssl context. I created https://gitlab.com/libssh/libssh-mirror/-/issues/278 |
We discussed this a bit over last couple of days and it looks like the libssh does not have the issue of multiple initializations. The pkcs11-provider is intialized correctly only once, but before we configure the test tokens, which leads to the failures. The proposed workaround for the upstream test suite would be to make sure we do not initialize pkcs11 provider too early by not using the global openssl configuration file: Usage of application specific openssl context would make it much more complicated, but it is still something we might consider in the future. |
The case I am worried about is a case where an application crates a new libctx and then decides to load an alternative config with a completely different token (like a softoken or a proprietary HSM driver). |
Describe the feature
Some applications might load the provider explicitly. At the same time if openssl contains provider configuration, it initialize it too. This can lead to some potential problems, e.g. the one described in https://issues.redhat.com/browse/RHEL-62713. If possible, the pkcs11-provider should prevent multiple initializations by some kind of locking mechanism.
Expected behavior
Application is able to correctly use the pkcs11-provider even when it explicitly loads it while it is already activated by openssl configuration.
The text was updated successfully, but these errors were encountered: