Skip to content

Support OpenSSL Providers #13115

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
wants to merge 6 commits into from
Closed

Conversation

tsturzl
Copy link

@tsturzl tsturzl commented Jun 26, 2025

We've been trying to use pyOpenSSL to leverage private keys stored in a TPM or PKCS#11 store, however this project doesn't currently support the ability to load a provider. To load a provider you must create an OSSL_LIB_CTX which can then be used with OSSL_PROVIDER_load. Once you have the OSSL_LIB_CTX with the provider loaded in, you can then pass that context into SSL_CTX_new_ex to create an SSL Context with that provider, and you can also load objects with the provider using the OSSL_STORE API using the OSSL_STORE_open_ex function.

I've only added in functions that are available in OpenSSL 3.0 to keep support simple, as that seems to be the minimally supported version for this project. My hope is that by adding this support that I can implement some basic provider support in pyOpenSSL, which can then be used to establish TLS connections utilizing HMS/TPM secured keys and certificates.

I've tested manually, but if you'd like I can add some basic unit tests it just doesn't seem like many of these CFFI bindings currently are being tested.

@alex
Copy link
Member

alex commented Jun 27, 2025

Thanks for this PR, however it's not going to be possible to accept in this form. First, our usage of cffi is long-term deprecated, and thus we're not adding any new bindings. However, more fundamentally we think that the providers APIs in OpenSSL are mis-designed and thus any APIs that we want to expose really need to be more generic ways for interacting with keys that don't live in memory. If you're interested in this area, I'd encourage you to file an issue and start a discussion, because this is a big area.

@alex alex closed this Jun 27, 2025
@tsturzl
Copy link
Author

tsturzl commented Jun 27, 2025

@alex I'd be interested in helping. I have a decent amount of experience with pkcs11 which seems to probably be the most broad and best supported standard for mediating this kind of indirect access.

I understand that pyca/cryptography is much broader than just integrating with OpenSSL, but it does seem odd that all of the FFI bindings is in this project for pyopenSSL, a project which is specifically a wrapper around OpenSSL. So to me it seems perfectly fair to say that this doesn't belong in THIS project, but to say it doesn't belong is pyOpenSSL does seem pretty confusing to me, though I get the two seem pretty well intertwined now it leaves me to wonder what pyopenSSL is intended for if it's just never going to expose any new APIs from the library is wraps. So to some extent this is just frustrating, because yes I understand that you might have different designs intentions, but that's now limiting the ability to really support a wide range of OpenSSL functionality in the pyOpenSSL project. From a pragmatic standpoint, OpenSSL has this and it works, and I'd like to just use it as is. It would be nice if pyopenSSL could implement this and this project could solve the problem in a way it finds more suitable. Alas, apparently that cannot be done.

Is there conversation on removing this as a dependency or pyopenssl if this project is deprecating CFFI bindings? Or does everything now need to move through rust and 2 separate compiler tool chains just to land in pyopenssl?

@alex
Copy link
Member

alex commented Jun 27, 2025

Our current focus is on deprecating legacy APIs in pyOpenSSL (pyca/pyopenssl#1321), removing unsafe behaviors (pyca/pyopenssl#1429), and then we intend to migrate pyopenssl to Rust for maintainability (#12378).

@tsturzl
Copy link
Author

tsturzl commented Jun 27, 2025

@alex would the goal be to support something like PKCS#11 in a way that does not really on OpenSSL at all? Or to just abstract some kind of OpenSSL provider interactions? Is PKCS#11 support in line with the overall design goal? Or would it be some broader support akin to OpenSSL providers? I'm not really sure what kind of ticket to open or what kind of conversation to start. It seems like there's a lot of design goals that I'm not exactly clued into or have any real strong opinions on.

@alex
Copy link
Member

alex commented Jun 27, 2025 via email

@tsturzl tsturzl mentioned this pull request Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants