Bug 266680 - security/py-openssl: Update to 23.2.0
Summary: security/py-openssl: Update to 23.2.0
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Li-Wen Hsu
URL: https://reviews.freebsd.org/D39037
Keywords: needs-qa
Depends on: 254853
Blocks: 273473
  Show dependency treegraph
 
Reported: 2022-09-28 15:01 UTC by Ivan Rozhuk
Modified: 2023-08-31 19:14 UTC (History)
21 users (show)

See Also:
sbz: maintainer-feedback+


Attachments
patch (2.07 KB, patch)
2022-09-28 15:01 UTC, Ivan Rozhuk
no flags Details | Diff
patch to 23.2.0 (1.22 KB, patch)
2023-07-23 14:04 UTC, Brad Davis
no flags Details | Diff
integrated patch (2.69 KB, patch)
2023-08-31 12:20 UTC, Li-Wen Hsu
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Rozhuk 2022-09-28 15:01:57 UTC
Created attachment 236916 [details]
patch
Comment 1 Ivan Rozhuk 2022-09-28 15:02:52 UTC
Requires security/py-cryptography 38.0.0+ from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254853
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2022-12-13 21:47:34 UTC
(In reply to Ivan Rozhuk from comment #1)

Whats the nature of the update dependency?
Comment 3 Kubilay Kocak freebsd_committer freebsd_triage 2022-12-13 21:49:00 UTC
We're in a timeout situation here, and this blocks a twisted update, which caused a regressions when recently updated.
Comment 4 Ivan Rozhuk 2022-12-14 04:10:21 UTC
(In reply to Kubilay Kocak from comment #2)

Upstream requires fresh py-cryptography:
https://github.com/pyca/pyopenssl/blob/main/setup.py
Comment 5 Charlie Li freebsd_committer freebsd_triage 2022-12-14 23:01:39 UTC
In the interim, update this to 21.0.0 instead, where the cryptography requirement is 3.3.
Comment 6 Sofian Brabez freebsd_committer freebsd_triage 2023-02-06 18:49:19 UTC
Also, be careful with this upgrade, it seems new version of py-crytopgraphy requires support for rust to be built.

If someone was to take the maintainership of security/py-openssl, please go ahead and do it.
Comment 7 Enji Cooper freebsd_committer freebsd_triage 2023-03-13 06:09:07 UTC
The latest version is now 23.0.0.
Comment 8 Enji Cooper freebsd_committer freebsd_triage 2023-03-13 09:01:28 UTC
(In reply to Sofian Brabez from comment #6)

I submitted the py-cryptography upgrade diff -- waiting for feedback (need to do a poudriere run), but FWIW... the diff I posted works once py-cryptography is updated according to the tests bundled with py-openssl.
Comment 9 Brad Davis freebsd_committer freebsd_triage 2023-07-23 14:04:25 UTC
Created attachment 243568 [details]
patch to 23.2.0

New patch for 23.2.0
Comment 10 Brad Davis freebsd_committer freebsd_triage 2023-07-24 13:24:26 UTC
devel/py-awscli (and I am sure others) will need this when bug 254853 lands.
Comment 11 Po-Chuan Hsieh freebsd_committer freebsd_triage 2023-08-22 17:09:04 UTC
Please use this one. Thanks.
https://people.freebsd.org/~sunpoet/patch/security-py-openssl.txt
Comment 12 Enji Cooper freebsd_committer freebsd_triage 2023-08-23 00:07:55 UTC
Hi sunpoet -- is there a reason why the patches you're posting (for this and bug 254853) aren't making it into the ports tree?
Comment 13 László Károlyi 2023-08-29 23:50:12 UTC
(In reply to Po-Chuan Hsieh from comment #11)
Can we have this patch actually added to the ports tree since py-cryptography is now updated?

This patch fixes a lot of things around cryptography in python.
Comment 14 Jonathan Chen 2023-08-30 21:27:16 UTC
Please commit this update to the ports, as py-openssl 21.0.0 does not work with py-cryptography 41.0.3. ie:

1:09pm> python3
Python 3.9.17 (main, Jun 16 2023, 03:51:47) 
[Clang 15.0.7 (https://github.com/llvm/llvm-project.git llvmorg-15.0.7-0-g8dfdc on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> import OpenSSL
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/local/lib/python3.9/site-packages/OpenSSL/crypto.py", line 3279, in <module>
    _lib.OpenSSL_add_all_algorithms()
AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'
>>>
Comment 15 Charlie Li freebsd_committer freebsd_triage 2023-08-31 00:32:04 UTC
Not so fast.

Since we have both mainline and legacy cryptography ports, with a DEFAULT_VERSIONS knob to boot, this port actually has to provide both versions, gated on the set DEFAULT_VERSIONS. Different PyOpenSSL consume different parts of the cryptography API, to the point where cryptography cannot remove/deprecate API portions within certain version ranges to preserve compatibility. See past revisions of the cryptography port (iirc) for inspo on how to do this, before I get to it.
Comment 16 Li-Wen Hsu freebsd_committer freebsd_triage 2023-08-31 09:59:30 UTC
(In reply to Charlie Li from comment #15)
I think it's not hurry now, as currently there is no consumer of py-cryptography-legacy or the direct consumer of legacy py-openssl (which uses py-cryptography-legacy) so we can update py-openssl to let its consumers working first. We can add py-openssl-legacy when needed.
Comment 17 bagas 2023-08-31 10:35:18 UTC
Hello.

py39-certbot-2.6.0,1               =   up-to-date with index
py39-josepy-1.13.0                 =   up-to-date with index
py39-openssl-21.0.0,1              =   up-to-date with index
python39-3.9.17                    =   up-to-date with index
py39-cryptography-41.0.3,1         =   up-to-date with index

 # certbot -q renew --allow-subset-of-names
Traceback (most recent call last):
  File "/usr/local/bin/certbot", line 33, in <module>
    sys.exit(load_entry_point('certbot==2.6.0', 'console_scripts', 'certbot')())
  File "/usr/local/bin/certbot", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/local/lib/python3.9/importlib/metadata.py", line 86, in load
    module = import_module(match.group('module'))
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/local/lib/python3.9/site-packages/certbot/main.py", line 6, in <module>
    from certbot._internal import main as internal_main
  File "/usr/local/lib/python3.9/site-packages/certbot/_internal/main.py", line 21, in <module>
    import josepy as jose
  File "/usr/local/lib/python3.9/site-packages/josepy/__init__.py", line 40, in <module>
    from josepy.json_util import (
  File "/usr/local/lib/python3.9/site-packages/josepy/json_util.py", line 14, in <module>
    from OpenSSL import crypto
  File "/usr/local/lib/python3.9/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/local/lib/python3.9/site-packages/OpenSSL/crypto.py", line 3279, in <module>
    _lib.OpenSSL_add_all_algorithms()
AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'

How to fix?
Comment 18 Li-Wen Hsu freebsd_committer freebsd_triage 2023-08-31 12:20:35 UTC
Created attachment 244518 [details]
integrated patch
Comment 19 commit-hook freebsd_committer freebsd_triage 2023-08-31 13:29:46 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=11e8f3c89438ceef19d425937a4e9de5085f9002

commit 11e8f3c89438ceef19d425937a4e9de5085f9002
Author:     Li-Wen Hsu <lwhsu@FreeBSD.org>
AuthorDate: 2023-08-31 13:27:26 +0000
Commit:     Li-Wen Hsu <lwhsu@FreeBSD.org>
CommitDate: 2023-08-31 13:27:26 +0000

    security/py-openssl: Update to 23.2.0

    This patch combines the efforts from the people invloved in the PR.
    I just do the integrating and testing.

    PR:             266680
    Approved by:    sbz (earlier version)
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D39037

 security/py-openssl/Makefile | 24 +++++++++---------------
 security/py-openssl/distinfo |  6 +++---
 2 files changed, 12 insertions(+), 18 deletions(-)
Comment 20 László Károlyi 2023-08-31 13:47:27 UTC
(In reply to commit-hook from comment #19)

Can confirm this patch/update works, it fixed my policyd-spf (that uses py-openssl) problem.

Cheers,
László
Comment 21 Enji Cooper freebsd_committer freebsd_triage 2023-08-31 17:03:50 UTC
(In reply to Li-Wen Hsu from comment #16)

We will need to come up with a story around these -legacy vs non-legacy consumers: the -legacy ones will need to be marked broken on >=3.x and the non-legacy ones need to be marked broken on <3.x--otherwise the package builders are going to complain because of OpenSSL in base in 12.x/13.x.

It's a bit of a tricky pickle too because of upstream ports deprecating support for OpenSSL 1.1--for good reason since it's EOL in another month--but that's a side-discussion for a different forum.
Comment 22 Charlie Li freebsd_committer freebsd_triage 2023-08-31 19:14:13 UTC
(In reply to Li-Wen Hsu from comment #16)
Anyone who sets legacy for the cryptography DEFAULT_VERSIONS is a consumer. While not visible on say FreshPorts or anything that tracks the default DEFAULT_VERSIONS, you still have to account for those cases.

A separate PyOpenSSL-legacy port is not feasible or in users' best interest in any case, since it would involve not only a new port, but possibly even an additional DEFAULT_VERSIONS knob. Such would only cause more confusion for users, who should not need to closely track cryptography and PyOpenSSL's development, to figure out which combination works with what. There is no API compatibility guarantee between different versions of the two packages, and because the two packages do not sync development or releases between themselves, some contention in this area has and will continue to happen. Hence why the best approach is to provide both 21.0.0 and whatever the current version is/becomes in the same port, gated on the DEFAULT_VERSIONS setting.