Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 937889 - app-crypt/certbot-2.10.0 outputs CryptographyDeprecationWarnings if >=dev-python/cryptography-43.0.0 is used
Summary: app-crypt/certbot-2.10.0 outputs CryptographyDeprecationWarnings if >=dev-pyt...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Matthew Thode ( prometheanfire )
URL: https://github.com/certbot/certbot/is...
Whiteboard:
Keywords: PullRequest
Depends on: 943522
Blocks:
  Show dependency tree
 
Reported: 2024-08-13 23:19 UTC by Philippe Chaintreuil
Modified: 2024-11-15 16:57 UTC (History)
19 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Modified patch to include CryptographyDeprecationWarning import (certbot.patch,2.41 KB, patch)
2024-10-13 10:56 UTC, Ian Pickworth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Chaintreuil 2024-08-13 23:19:13 UTC
If I'm understanding this upstream bug, certbot can't currently handle overly dev-python/cryptography-43.0.0 or newer.

https://github.com/certbot/certbot/issues/9967

=============================
/usr/lib/python3.12/site-packages/certbot/ocsp.py:238: CryptographyDeprecationWarning: Properties that return a naïve datetime object have been deprecated. Please switch to this_update_utc.
  if not response_ocsp.this_update:
/usr/lib/python3.12/site-packages/certbot/ocsp.py:240: CryptographyDeprecationWarning: Properties that return a naïve datetime object have been deprecated. Please switch to this_update_utc.
  if response_ocsp.this_update > now + timedelta(minutes=5):
/usr/lib/python3.12/site-packages/certbot/ocsp.py:242: CryptographyDeprecationWarning: Properties that return a naïve datetime object have been deprecated. Please switch to next_update_utc.
  if response_ocsp.next_update and response_ocsp.next_update < now - timedelta(minutes=5):
=============================

Until upstream fixes their bug, Gentoo probably needs to disallow the current ebuild from using the new cryptography package.

Reproducible: Always
Comment 1 Philippe Chaintreuil 2024-08-13 23:20:27 UTC
Forgot to state: this is output when running certbot renew.
Comment 2 Phil Stracchino (Unix Ronin) 2024-08-15 15:15:02 UTC
(In reply to Philippe Chaintreuil from comment #0)
> If I'm understanding this upstream bug, certbot can't currently handle
> overly dev-python/cryptography-43.0.0 or newer.
> 
> https://github.com/certbot/certbot/issues/9967
> 
> =============================
> /usr/lib/python3.12/site-packages/certbot/ocsp.py:238:
> CryptographyDeprecationWarning: Properties that return a naïve datetime
> object have been deprecated. Please switch to this_update_utc.
>   if not response_ocsp.this_update:
> /usr/lib/python3.12/site-packages/certbot/ocsp.py:240:
> CryptographyDeprecationWarning: Properties that return a naïve datetime
> object have been deprecated. Please switch to this_update_utc.
>   if response_ocsp.this_update > now + timedelta(minutes=5):
> /usr/lib/python3.12/site-packages/certbot/ocsp.py:242:
> CryptographyDeprecationWarning: Properties that return a naïve datetime
> object have been deprecated. Please switch to next_update_utc.
>   if response_ocsp.next_update and response_ocsp.next_update < now -
> timedelta(minutes=5):
> =============================
> 
> Until upstream fixes their bug, Gentoo probably needs to disallow the
> current ebuild from using the new cryptography package.
> 
> Reproducible: Always


Just noting I am also seeing exactly this.
Comment 3 Evert 2024-09-10 15:23:04 UTC
Confirmed, same here ...
Comment 4 Axel Drogoin 2024-09-16 22:14:06 UTC
I've added

PYTHONWARNINGS=ignore

before

certbot renew --quiet

in crontab as a workaround for now
Comment 5 Philippe Chaintreuil 2024-09-26 00:48:45 UTC
Upstream doesn't seem like they're going to be very responsive[1] to addressing these warnings. Feels like they'll get to upgrading to cryptography 43.0.0 when they feel like it.

So, since Gentoo only has cryptography 43.0.x in the tree at this point, lets just patch in the fix. The certbot code is already dealing in UTC, so it seems pretty straight forward.


PR: https://github.com/gentoo/gentoo/pull/38775


If maintainers want tweaks, I'm happy to make them.  If they don't want it at all, no hard feelings.

[1] https://github.com/certbot/certbot/issues/9967#issuecomment-2251124561
Comment 6 Eli Schwartz gentoo-dev 2024-09-27 04:44:48 UTC
Perhaps someone should just open a PR with upstream that adds the if/else or try/except?
Comment 7 Philippe Chaintreuil 2024-09-27 09:58:51 UTC
My Python kungfu isn't strong enough for an upstream patch.  This is a warning, not an exception, so try/catch won't trigger to my knowledge.  And I don't know how to reliably version check a library.  And I don't know how to test against old versions of the library to confirm changes are working as expected.

Since we have removed old cryptography versions, the fix in our scope was more straightforward.

But if someone else knows Python better, an upstream fix would be better.
Comment 8 Eli Schwartz gentoo-dev 2024-09-27 16:06:21 UTC
(In reply to Philippe Chaintreuil from comment #7)
> My Python kungfu isn't strong enough for an upstream patch.  This is a
> warning, not an exception, so try/catch won't trigger to my knowledge.  And
> I don't know how to reliably version check a library.  And I don't know how
> to test against old versions of the library to confirm changes are working
> as expected.


Well, you would first try "this_update_utc", which would be an exception if it doesn't exist, and if that exception occurs then you would try again using "this_update" to support older versions.
Comment 9 Philippe Chaintreuil 2024-09-28 20:18:57 UTC
I've stated other reasons I do not feel capable of offering code changes to upstream.  

You are welcome to do so though.
Comment 10 Eli Schwartz gentoo-dev 2024-09-29 01:52:38 UTC
I don't know what those reasons could be other than fear that they won't accept the change.

If you don't offer it, they certainly can't accept it. It is generally considered "the right thing to do" to offer patches upstream rather than turn the distro into a maze of downstream patches when it can be avoided.

Whether upstream accepts the patch or not is beside the point -- the point is to try.

(In reply to Philippe Chaintreuil from comment #9)
> You are welcome to do so though.

I don't use this package -- you do and Matthew (presumably) does.
Comment 11 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-10-05 05:36:29 UTC
I think it's reasonable for someone to be in a position where they've crafted a workaround that Works For Them, sharing it in case others are stuck, but aren't confident that it's correct / aren't currently able to interact with a (new) upstream and submit it and justify it and so on.

Let's leave it there on that.
Comment 12 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-10-05 05:40:28 UTC
Now, as for the fix itself: if you're not confident enough to submit it upstream (which is fine), I think we can go in another direction.

With patches that actually change something, I think it's reasonable to request (even demand) it be sent upstream if someone is proposing it actually be included in the ebuild.

We can avoid any semantic changes and just do the bare minimum to silence the deprecation warning, given upstream are already aware.
Comment 13 Larry the Git Cow gentoo-dev 2024-10-05 05:59:37 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6af2e1684b64a9e0d621903d02de17e3b8540a67

commit 6af2e1684b64a9e0d621903d02de17e3b8540a67
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-10-05 05:58:22 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-10-05 05:58:22 +0000

    app-crypt/certbot: workaround cryptography deprecation warnings
    
    Not ideal but the bug has been open a while and doing this as a drive-by;
    the upstream bug doesn't seem to be going anywhere either.
    
    Just suppress the dev-python/cryptography deprecation warnings for now
    given it's very vocal and shows up in cron jobs.
    
    Closes: https://bugs.gentoo.org/937889
    Signed-off-by: Sam James <sam@gentoo.org>

 app-crypt/certbot/certbot-2.11.0-r1.ebuild         | 69 ++++++++++++++++++++++
 ...karound-cryptography-deprecation-warnings.patch | 36 +++++++++++
 2 files changed, 105 insertions(+)
Comment 14 Philippe Chaintreuil 2024-10-05 18:14:08 UTC
Thanks Sam!

I didn't even realize one could locally suppress warning like that in Python.
Comment 15 Philippe Chaintreuil 2024-10-06 17:58:27 UTC
@sam, the patch doesn't work.

==================================================================
/usr/lib/python3.12/site-packages/certbot/ocsp.py:248: CryptographyDeprecationWarning: Properties that return a naïve datetime object have been deprecated. Please switch to next_update_utc.
==================================================================

You've got...

==================================================================
warnings.filterwarnings("ignore",category=DeprecationWarning)
==================================================================

... in the patch, but it's actually of type "CryptographyDeprecationWarning" (which subclasses from UserWarning, not DeprecationWarning for some reason [1]).

If I change that line in the patch to ...

==================================================================
warnings.filterwarnings("ignore",category=CryptographyDeprecationWarning)
==================================================================

... it does work & it does suppress the log spam.



[1] https://github.com/pyca/cryptography/blob/56933bf61a4539a1306534a196e67e40c5084719/src/cryptography/utils.py#L16C38-L16C49
Comment 16 Eli Schwartz gentoo-dev 2024-10-06 18:04:11 UTC
(In reply to Sam James from comment #11)
> I think it's reasonable for someone to be in a position where they've
> crafted a workaround that Works For Them, sharing it in case others are
> stuck, but aren't confident that it's correct / aren't currently able to
> interact with a (new) upstream and submit it and justify it and so on.
> 
> Let's leave it there on that.

As we can see, that worked out well. :)

I specifically had questions about people being in the position you describe for the specific reason of the specificity inherent in:

"Upstream doesn't seem like they're going to be very responsive"

therefore

"I don't feel confident submitting an upstream patch"

I didn't think this was a good reason, and I still don't think it's a good reason...
Comment 17 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-10-09 10:30:01 UTC
Oops, thanks!
Comment 18 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-10-09 10:31:13 UTC
(In reply to Eli Schwartz from comment #16)
> (In reply to Sam James from comment #11)
> > I think it's reasonable for someone to be in a position where they've
> > crafted a workaround that Works For Them, sharing it in case others are
> > stuck, but aren't confident that it's correct / aren't currently able to
> > interact with a (new) upstream and submit it and justify it and so on.
> > 
> > Let's leave it there on that.
> 
> As we can see, that worked out well. :)

No comment ;)
Comment 19 Larry the Git Cow gentoo-dev 2024-10-09 10:32:02 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5180e4596a18e5f17b23364643c9d50b52e33f21

commit 5180e4596a18e5f17b23364643c9d50b52e33f21
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-10-09 10:31:26 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-10-09 10:31:26 +0000

    app-crypt/certbot: fix deprecation warning name
    
    Closes: https://bugs.gentoo.org/937889
    Fixes: 6af2e1684b64a9e0d621903d02de17e3b8540a67
    Signed-off-by: Sam James <sam@gentoo.org>

 .../certbot/{certbot-2.11.0-r1.ebuild => certbot-2.11.0-r2.ebuild}      | 0
 .../certbot-2.11.0-workaround-cryptography-deprecation-warnings.patch   | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
Comment 20 Ian Pickworth 2024-10-13 10:42:56 UTC
Sorry to post on a closed issue, but this patch gives a runtime error for me:

ian ~ # certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log
An unexpected error occurred:
NameError: name 'CryptographyDeprecationWarning' is not defined
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.
ian ~ # 

Since this appears to work for others, any pointers as to what I can look for to find/insert the CryptographyDeprecationWarning definition?
Comment 21 Ian Pickworth 2024-10-13 10:51:09 UTC
(In reply to Ian Pickworth from comment #20)
> Sorry to post on a closed issue, but this patch gives a runtime error for me:
> 
> ian ~ # certbot certificates
> Saving debug log to /var/log/letsencrypt/letsencrypt.log
> An unexpected error occurred:
> NameError: name 'CryptographyDeprecationWarning' is not defined
> Ask for help or search for solutions at https://community.letsencrypt.org.
> See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with
> -v for more details.
> ian ~ # 
> 
> Since this appears to work for others, any pointers as to what I can look
> for to find/insert the CryptographyDeprecationWarning definition?

My limited python skills found that, to get the patch to work, the following import statement has to be added to the patch (in the cryptography import code block):

from cryptography.utils import CryptographyDeprecationWarning
Comment 22 Ian Pickworth 2024-10-13 10:56:12 UTC
Created attachment 905593 [details, diff]
Modified patch to include CryptographyDeprecationWarning import

Added an import statement for CryptographyDeprecationWarning to the original deprecation warning removal patch
Comment 23 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-10-13 14:49:08 UTC
I'm embarrassed to say that I think Eli was proven right. Anyway, as penance, I'll fix it properly upstream as well.
Comment 24 Larry the Git Cow gentoo-dev 2024-10-14 00:33:33 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=83f5bc98f8cfe888e5a62ef61a215dce575c5b6c

commit 83f5bc98f8cfe888e5a62ef61a215dce575c5b6c
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-10-14 00:32:43 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-10-14 00:32:43 +0000

    app-crypt/certbot: drop workaround patch
    
    I'm going to do it properly later tonight hopefully.
    
    Bug: https://bugs.gentoo.org/937889
    Signed-off-by: Sam James <sam@gentoo.org>

 .../certbot/{certbot-2.11.0-r2.ebuild => certbot-2.11.0-r3.ebuild}    | 4 ----
 1 file changed, 4 deletions(-)
Comment 25 Philippe Chaintreuil 2024-11-14 19:23:56 UTC
> certbot 3.0.1 containing a fix for this has now been released

https://github.com/certbot/certbot/issues/9967#issuecomment-2477224504

Release notes: https://github.com/certbot/certbot/releases/tag/v3.0.1
Comment 26 Eli Schwartz gentoo-dev 2024-11-14 20:10:43 UTC
Great -- can you submit a PR containing the new release? :)
Comment 27 Larry the Git Cow gentoo-dev 2024-11-15 16:57:06 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fa2b0c81fd002c90b796b62dc234247c5fdf7f13

commit fa2b0c81fd002c90b796b62dc234247c5fdf7f13
Author:     Thibaud CANALE <thican@thican.net>
AuthorDate: 2024-11-14 19:31:57 +0000
Commit:     Matthew Thode <prometheanfire@gentoo.org>
CommitDate: 2024-11-15 16:46:24 +0000

    app-crypt/certbot: add 3.0.1
    
    Closes: https://bugs.gentoo.org/937889
    Closes: https://bugs.gentoo.org/943522
    Signed-off-by: Thibaud CANALE <thican@thican.net>
    Closes: https://github.com/gentoo/gentoo/pull/39320
    Signed-off-by: Matthew Thode <prometheanfire@gentoo.org>

 app-crypt/certbot/Manifest             |  1 +
 app-crypt/certbot/certbot-3.0.1.ebuild | 66 ++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7fe0979184963745d8035b690e9362cce9c333b8

commit 7fe0979184963745d8035b690e9362cce9c333b8
Author:     Thibaud CANALE <thican@thican.net>
AuthorDate: 2024-11-14 19:30:22 +0000
Commit:     Matthew Thode <prometheanfire@gentoo.org>
CommitDate: 2024-11-15 16:46:23 +0000

    app-crypt/acme: add 3.0.1
    
    Closes: https://bugs.gentoo.org/937889
    Closes: https://bugs.gentoo.org/943522
    Signed-off-by: Thibaud CANALE <thican@thican.net>
    Signed-off-by: Matthew Thode <prometheanfire@gentoo.org>

 app-crypt/acme/Manifest          |  1 +
 app-crypt/acme/acme-3.0.1.ebuild | 65 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+)