-
Notifications
You must be signed in to change notification settings - Fork 29
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
testing idea to migrate from pyopenssl onto cryptography (#1) #196
base: master
Are you sure you want to change the base?
Conversation
* testing idea to migrate from pyopenssl onto cryptography
stashed the legacy objects to aid in migration
Thanks for testing this out! My main question is if the primary benefit of this PR is to preserve backwards compatibility, and if so, is that needed? Assume we want to remove Or is the goal to just remove the pyopenssl usage now, without worrying about the larger project of decoupling certbot from josepy custom types? On a more practical note, |
Ack. those were failing after submitting this PR, and supposed to be committed into my in-process branch - not the PR one. I'll get those working even if just for me.
Basically that. I wanted to offer the most minimally breaking change conceivable to get Certbot off pyopenssl immediately, as I do think the concerns raised in #5 over third-party libraries utilizing Rather than giving impacted projects a mandate to "pin or upgrade", anything affected could do a temporary migration to the I am perhaps too influenced with SqlAlchemy, which goes to extreme measures to prepare users for API changes well in advance of breaking changes. |
bump cryptography version address mypy issue
it seems my local virtualenv got broken or conflicted, which kept the pre-commits from running correctly or at all. rebuilding got everything to work correctly. I'm not sure why the external test is failing here for openssl build errors; it passes elsewhere. the minimum version of cryptography had to be bumped to 42, to support timezone aware datetime objects. that version bump should probably happen in this project no matter what, as the timezone agnostic interfaces are deprecated. i was dealing with randomly failing tests, because each testrunner used a different cryptography version. |
That seems like a valid motivation; I confess I was only thinking of josepy in terms of its use as a certbot dependency and hasn't realized that other projects do seem to use it as well. It's more popular than I realized. As for the error: https://community.letsencrypt.org/t/certbot-renew-fails-no-attribute-x509-v-flag-notify-policy/215629/2
Sounds like since we need cryptography 42, gotta use a newer pyopenssl as well. |
Ah, that explains why it works on some runs but not others. Something I’ll do tomorrow is drop pyopenssl from requirements, and make it a conditional import (in try block). Then try to make tests run with and without pyopenssl, dropping some skip-unless options in there. I don’t know if any of this is useful to you all, but I could use the mental exercise:) |
If nothing else this discussion has certainly helped me realize how many people are using josepy which helps contextualize my thinking about it. I'm surprised that this PR gets us to where we could just drop pyopenssl as a requirement, even if conditionally. Or is that just to get a clearer picture of where it's still needed? |
That's exactly the plan. I just need to figure out how to get tox and poetry to handle this correctly. My thought was to migrate openssl into an optional dependency (i.e. josepy would then not require openssl, but use it if available (and compatible, I've got the version check handled). affected projects would then have to specify the openssl requirement in their code - which they already should be doing as they'd be doing something with the |
* conditional imports for pyopenssl * attempted, then removed version check for pyopenssl; it is guaranteed due to cryptography version(?) * edit pyproject.toml to make dependency optional * poetry lock update * removed unused `load_pyopenssl_private_key` * the tox does not use `extras` but its there for form. i did a full override on `commands_pre` because it was a nightmare trying to migrate the extras into that install command with overrides.
ok, so this works! cryptography is optional via a The test matrix is now doubled, running in "noopenssl" and "legacy" modes.
In In The only thing not supported is the pyopenssl text filetype, but I can't imagine that being used much. Anyways, my suggestion for an approach like this would be :
That would allow for certbot (and related projects) to drop pyopenssl for cryptography ASAP, and to drop pyopenssl from josepy in the near future - while giving any 3rd party projects a migration tool and minimally breaking their projects. As mentioned above - any breaking changes against unpinned projects will already require a hotfix version bump release, so instead of pinning to This was annoying, but fun, to get github+tox+poetry to work together nicely. |
Appreciate all the work you put in here! While I love the thoughtfulness for helping people migrate, I don't personally see the benefit of having people switch to |
I'm fine with dropping I think most of the breakage in those would be through tests; from what I remember the library code mostly doesn't rely on the internals of this object. |
Not to worry about certbot/acme; both are pinned to josepy |
This PR accepts the pyopenssl objects and converts them to cryptography objects. I can generate another pr that doesn’t do any of that.The main idea behind this was that it automatically upgrades legacy objects, and also offers a legacy interface, so projects can drop pyopenssl asap. I wanted to make it as easy and fast for everyone to get off it asap.I’ll make a no OpenSSL pr in another branch.On Dec 20, 2024, at 8:14 PM, ohemorange ***@***.***> wrote:
Not to worry about certbot/acme; both are pinned to josepy <2.0 for exactly this reason. What do you mean the packaging/testing concerns about accepting pyopenssl objects? Ideally we would no longer do so, no?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
I was testing this idea to migrate from pyopenssl onto cryptography, before being pointed to #182
This is a less backwards incompatible change than that PR.
ComparableX509
is retained, but the underlying storage is migrated from pyopenssl onto cryptography.The init still accepts the legacy objects, but transcodes them.
I patched in support for the only
getattr(ComparableX509.wrapped)
in the tests. If one wanted to go crazy, there could be a full mapping there for compatibility - however I don't think wrapped attributes should be interacted with.The actual tests pass, but precommit fails (even though i have precommit locally and i manually reordered the imports based on github runner output).
I think this approach might make it easier to move completely away from pyopenssl over a few iterations of the related projects.