-
Notifications
You must be signed in to change notification settings - Fork 30
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
Feature crypto backend2 #202
base: master
Are you sure you want to change the base?
Conversation
This is an idea for conditional usage with the new/legacy concept as discussed in #196, while still making pyOpenSSL a conditional import. I think this should not break compatibility, but I need more time to think about it. In this version:
All internal package functions reference On instantiation of
What I don't like about this and misc concerns:
There are a few other things I was concerned with, but I have too much brain frog now. Maybe one of the Cryptography maintainers can chime in with comments/concerns, as I know they're focused on getting Cerbot off PyOpenSSL as well. |
CHANGELOG.rst
Outdated
migrate code to the Cryptography objects. This is offered as a minimally | ||
breaking change to aid in migration to Cryptography. Affected projects should | ||
either pin to `1.14.0` or utilize the new attribute in a "hotfix" release. | ||
Please note, due to the removal of `X509_V_FLAG_NOTIFY_POLICY` in pyOpenSSL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain a bit more? Where does X509_V_FLAG_NOTIFY_POLICY
come into play? Not seeing it on a grep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A pretty smart developer on this project, @ohemorange, figured this out. Check out their comment in the other PR ;) : #196 (comment)
In terms of this causing issues...
This breaks the linting routine (the Python Tests for Josepy / external (pull_request)
test), if it picks up a system pyOpenSSL that is incompatible. I got around that by setting a compatible pyopenssl as a dev/testing requirement - however (going back to my concern 2 above), even though the code does not require PyOpenSSL to operate, it would probably be wise to list the minimum compatible version as a regular dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, but you see that was last-year @ohemorange, a person that this-year @ohemorange retains no memory of.
I still don't see why there would be a version conflict though, what's causing the conflict? Is this just saying that there will be a version conflict only if they don't update to the new required version (or remove pyopenssl entirely)? Or is there a conflicting pyopenssl requirement somewhere else, that is has to be under some version? We usually just write required version updates as "josepy now requires project version x.x.x," see https://github.com/certbot/certbot/pull/10130/files for an ongoing example.
And as I mentioned in my other comment, it's probably easiest to remove the pyopenssl requirement after this PR in one fell swoop rather than making it conditional, especially if it's both a conditional requirement and a dev/testing requirement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't see why there would be a version conflict though, what's causing the conflict?
The only time I've been able to trigger this is that test suite, and bunch of debugging/analysis suggests this is what happens:
PyOpenSSL
is not required byjosepy
or any dependencies, so is not installed into the virtualenv- The linter sees the
PyOpenSSL
import, and loads the system installation ofPyOpenSSL
or something from the last cached download - which sometimes (but not always) is an earlier version. - The linter picks up the incompatibility,
I don't think this would be triggered in production code - I think it's just a happenstance of the linter.
And as I mentioned in my other comment, it's probably easiest to remove the pyopenssl requirement after this PR in one fell swoop rather than making it conditional, especially if it's both a conditional requirement and a dev/testing requirement.
Agreed. I'm going to migrate PyOpenSSL into a requirement, but not use it. Then it can be dropped on the next release. If someone is still using PyOpenSSL, forcing them to use a more modern version makes sense.
Some thoughts: Dropping pyopenssl is of course nice, but conditional dependencies are a pain. Probably easier to just keep it around for now and drop it on next release than do the legacy thing. I don't see the benefit of asserting the wrapped cert type based on what's installed. Didn't realize that Once pyopenssl is totally gone, we don't technically need If we do want to get rid of |
These are good ideas, and I agree. I should have time to implement them tomorrow. In terms of the design motivations: Sometimes you spend so much time in the weeds, you forget to look at the sky.
I think this is what might be needed:
|
Thanks for that summary, that sounds mostly right to me. Thinking about your third bullet raises an interesting question -- should |
I feel like for migration purposes, the latter would be more useful, but might also be more in violation of backwards compatibility. Which may indicate a fundamental problem with this approach? |
Maybe we're overthinking this whole thing. Going back to basics, what we want here is for users to be able to use either pyopenssl or cryptography certs in their functions. If they're using cryptography, they don't actually need |
I think The This would preserve the interface for existing usage, migrate all josepy/acme/cert operations off of OpenSSL, and give the upgrade path (raw Cryptography objects). It looks like the relevant Cryptography objects support eq through the rust bindings |
If |
I had a thoughtful and insightful reply, and lost it due to iOS switching tabs. I hope to convince you with the next PR. |
Ok, here is the general idea: ComparableX509 is deprecated, but still exists for migration. It will accept Cryptography and PyOpenSSL objects. If anything (third party) touches All internal usage is 100% Cryptography The only issues: Breaking Change:
Migration Concerns:
Aside from the headers, this is as minimally a breaking change I can think of that gets 100% of library operations off of PyOpenSSL, and will not break any integrations that just pass Cryptography objects around. |
I really appreciate your efforts here, but I still think we can do be doing things way more minimally that allow for migration and are less prone to breakage. The key principles are
This is how we've been doing it in the certbot code, and it allows for a smooth transition period where new functionality in added in a update, and removed in a major update, and also allows for small modular changes, which are both easier to review and (therefore) statistically less likely to lead to bugs. By this logic, the updates inside of Edit: I do realize that this plan is slightly less than ideal when it comes to the future names of methods; Edit 2: I forgot about josepy fields and how things are done automagically here, I don't think we can in fact do something like |
Took a stab at the sort of smaller, more minimal change I'm talking about in #204, which is largely based on this PR, just pulling things out and changing them around to match the vision I described. |
After writing that PR, it occurs to me that maybe the reason you want to do the |
PR #196 got too out of date from the main branch, and there were too many messy merge-commits for tests to run; so this is just a manual diff to continue that branch/discussion and get tests running.