[Bug] Y2038 problem on x32-bit x86 system: FAILED certbot/_internal/tests/storage_test.py::RenewableCertTests::test_time_interval_judgments - OverflowError: timestamp out of range for platform time_t

未关闭
#10,296 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@bmw 已经在做这个了。

开始于 2025年5月29日。

评估

这个 Issue 还没有评估数据。

描述

OS

Gentoo

Installation method

emerge

Certbot Version

4.0.0

What happened?

When running tests on a 32-bit x86 system, with Python 3.11, test certbot/_internal/tests/storage_test.py::RenewableCertTests::test_time_interval_judgments fails because of an OverflowError (timestamp out of range for platform time_t). Surely related to the Y2038 problem.

Source: https://bugs.gentoo.org/955713
Attached log: certbot-4.0.0-r2_20250510-053719.log

Expected behavior

Running tests without errors, handling Y2038 problem if possible.

Relevant log output
=============================================================== FAILURES ===============================================================
___________________________________________ RenewableCertTests.test_time_interval_judgments ____________________________________________

self = <certbot._internal.tests.storage_test.RenewableCertTests testMethod=test_time_interval_judgments>
mock_datetime = <MagicMock name='datetime' id='4075854320'>, mock_set_by_user = <MagicMock name='set_by_user' id='4114767856'>

    @mock.patch.object(configuration.NamespaceConfig, 'set_by_user')
    @mock.patch("certbot._internal.storage.datetime")
    def test_time_interval_judgments(self, mock_datetime, mock_set_by_user):
        """Test should_autorenew() on the basis of expiry time windows."""
        # Note: this certificate happens to have a lifetime of 7 days,
        # and the tests below that use a "None" interval (i.e. choose a
        # default) rely on that fact.
        #
        # Not Before: Dec 11 22:34:45 2014 GMT
        # Not After : Dec 18 22:34:45 2014 GMT
        not_before = datetime.datetime(2014, 12, 11, 22, 34, 45)
        short_cert = make_cert_with_lifetime(not_before, 7)

        self._write_out_ex_kinds()

        self.test_rc.update_all_links_to(12)
        with open(self.test_rc.cert, "wb") as f:
            f.write(short_cert)
        self.test_rc.update_all_links_to(11)
        with open(self.test_rc.cert, "wb") as f:
            f.write(short_cert)

        mock_datetime.timedelta = datetime.timedelta
        mock_set_by_user.return_value = False
        self.test_rc.configuration["renewalparams"] = {}

        for (current_time, interval, result) in [
                # 2014-12-13 12:00 (about 5 days prior to expiry)
                # Times that should result in autorenewal/autodeployment
                (1418472000, "2 months", True), (1418472000, "1 week", True),
                # With the "default" logic, this 7-day certificate should autorenew
                # at 3.5 days prior to expiry. We haven't reached that yet,
                # so don't renew.
                (1418472000, None, False),
                # 2014-12-16 03:20, a little less than 3.5 days to expiry.
                (1418700000, None, True),
                # Times that should not renew
                (1418472000, "4 days", False), (1418472000, "2 days", False),
                # 2009-05-01 12:00:00+00:00 (about 5 years prior to expiry)
                # Times that should result in autorenewal/autodeployment
                (1241179200, "7 years", True),
                (1241179200, "11 years 2 months", True),
                # Times that should not renew
                (1241179200, "8 hours", False), (1241179200, "2 days", False),
                (1241179200, "40 days", False), (1241179200, "9 months", False),
                # 2015-01-01 (after expiry has already happened, so all
                #            intervals should cause autorenewal/autodeployment)
                (1420070400, "0 seconds", True),
                (1420070400, "10 seconds", True),
                (1420070400, "10 minutes", True),
                (1420070400, "10 weeks", True), (1420070400, "10 months", True),
                (1420070400, "10 years", True), (1420070400, "99 months", True),
                (1420070400, None, True)
        ]:
            sometime = datetime.datetime.fromtimestamp(current_time, pytz.UTC)
            mock_datetime.datetime.now.return_value = sometime
            self.test_rc.configuration["renew_before_expiry"] = interval
            assert self.test_rc.should_autorenew() == result

        # Lifetime: 31 years
        # Default renewal: about 10 years from expiry
        # Not Before: May 29 07:42:01 2017 GMT
        # Not After : Mar 30 07:42:01 2048 GMT
        not_before=datetime.datetime(2017, 5, 29, 7, 42, 1)
        long_cert = make_cert_with_lifetime(not_before, 31 * 365)
        self.test_rc.update_all_links_to(12)
        with open(self.test_rc.cert, "wb") as f:
            f.write(long_cert)
        self.test_rc.update_all_links_to(11)
        with open(self.test_rc.cert, "wb") as f:
            f.write(long_cert)
        for (current_time, result) in [
            (2114380800, False), # 2037-01-01
            (2148000000, True), # 2038-01-25
        ]:
>           sometime = datetime.datetime.fromtimestamp(current_time, pytz.UTC)
E           OverflowError: timestamp out of range for platform time_t

current_time = 2148000000
f          = <_io.BufferedWriter name='/var/tmp/portage/app-crypt/certbot-4.0.0-r2/temp/tmpke65_o4t/config/live/example.org/cert.pem'>
interval   = None
long_cert  = (b'-----BEGIN CERTIFICATE-----\nMIIBHDCBwqADAgECAhQFtQAt7z74T4ZaHwjU0qNQtM8Z'
 b'XjAKBggqhkjOPQQDAjAA\nMB4XDTE3MDUyOTA3NDIwMVoXDTQ4MDUyMTA3NDIwMVowADBZMBM'
 b'GByqGSM49AgEG\nCCqGSM49AwEHA0IABBRoa2UVIghjOqGdR16FBQZtPIC1rY0PjO/k9mvIAh'
 b'feV3cs\nxmoNy8BWTpo7mxt4ceW+3e7pkJveN71kEoAKIlejGjAYMBYGA1UdEQQPMA2CC2V4\n'
 b'YW1wbGUuY29tMAoGCCqGSM49BAMCA0kAMEYCIQDbRZRW+T+bRpFcw0s0KqgL5qfs\nfrfGUjQ'
 b'hNib7ZFITvgIhAL2g1C/VGVsvA0kufGBJmKUdFgawqw9jyhzy8TqQp5kI\n-----END CERTI'
 b'FICATE-----\n')
mock_datetime = <MagicMock name='datetime' id='4075854320'>
mock_set_by_user = <MagicMock name='set_by_user' id='4114767856'>
not_before = datetime.datetime(2017, 5, 29, 7, 42, 1)
result     = True
self       = <certbot._internal.tests.storage_test.RenewableCertTests testMethod=test_time_interval_judgments>
short_cert = (b'-----BEGIN CERTIFICATE-----\nMIIBGzCBwqADAgECAhQ3tZx2//Jk2IVd/dc8FrGqRh+D'
 b'3DAKBggqhkjOPQQDAjAA\nMB4XDTE0MTIxMTIyMzQ0NVoXDTE0MTIxODIyMzQ0NVowADBZMBM'
 b'GByqGSM49AgEG\nCCqGSM49AwEHA0IABL3wCkzdeedPLAracZAFrR5VpmaUyIkVZZeLOkmWjR'
 b'xnxQkq\nuwXoBSJ4th+wxlHAl1sZVlqzUe3kQW0ha7sTlH2jGjAYMBYGA1UdEQQPMA2CC2V4\n'
 b'YW1wbGUuY29tMAoGCCqGSM49BAMCA0gAMEUCIQDvcFi/HEPzkccBapjiFbQptWId\nQD35nSl'
 b'8LyWxLPHq/wIgAhIZFnw+cXkinEVJr2NdihSqHBdFH7NyoZGEVlASpPk=\n-----END CERTI'
 b'FICATE-----\n')
sometime   = datetime.datetime(2037, 1, 1, 0, 0, tzinfo=<UTC>)

certbot/_internal/tests/storage_test.py:544: OverflowError
---------------------------------------------------------- Captured log call -----------------------------------------------------------
DEBUG    certbot._internal.storage:storage.py:1012 Should renew, less than 2 months before certificate expiry 2014-12-18 22:34:45 UTC.
DEBUG    certbot._internal.storage:storage.py:1012 Should renew, less than 1 week before certificate expiry 2014-12-18 22:34:45 UTC.
DEBUG    certbot._internal.storage:storage.py:1025 Should renew, less than 3 days, 12:00:00s before certificate expiry 2014-12-18 22:34:45 UTC.
DEBUG    certbot._internal.storage:storage.py:1012 Should renew, less than 7 years before certificate expiry 2014-12-18 22:34:45 UTC.
DEBUG    certbot._internal.storage:storage.py:1012 Should renew, less than 11 years 2 months before certificate expiry 2014-12-18 22:34:45 UTC.
DEBUG    certbot._internal.storage:storage.py:1012 Should renew, less than 0 seconds before certificate expiry 2014-12-18 22:34:45 UTC.
DEBUG    certbot._internal.storage:storage.py:1012 Should renew, less than 10 seconds before certificate expiry 2014-12-18 22:34:45 UTC.
DEBUG    certbot._internal.storage:storage.py:1012 Should renew, less than 10 minutes before certificate expiry 2014-12-18 22:34:45 UTC.
DEBUG    certbot._internal.storage:storage.py:1012 Should renew, less than 10 weeks before certificate expiry 2014-12-18 22:34:45 UTC.
DEBUG    certbot._internal.storage:storage.py:1012 Should renew, less than 10 months before certificate expiry 2014-12-18 22:34:45 UTC.
DEBUG    certbot._internal.storage:storage.py:1012 Should renew, less than 10 years before certificate expiry 2014-12-18 22:34:45 UTC.
DEBUG    certbot._internal.storage:storage.py:1012 Should renew, less than 99 months before certificate expiry 2014-12-18 22:34:45 UTC.
DEBUG    certbot._internal.storage:storage.py:1025 Should renew, less than 3 days, 12:00:00s before certificate expiry 2014-12-18 22:34:45 UTC.
INFO     certbot.ocsp:ocsp.py:149 Cannot extract OCSP URI from /var/tmp/portage/app-crypt/certbot-4.0.0-r2/temp/tmpke65_o4t/config/archive/example.org/cert12.pem
=========================================================== warnings summary ===========================================================
acme/_internal/tests/crypto_util_test.py::SSLSocketAndProbeSNITest::test_probe_ok
  /var/tmp/portage/app-crypt/certbot-4.0.0-r2/work/certbot-4.0.0-python3_11/install/usr/lib/python3.11/site-packages/acme/crypto_util.py:136: DeprecationWarning: Passing pyOpenSSL PKey objects is deprecated. You should use a cryptography private key instead.
    new_context.use_privatekey(key)

acme/_internal/tests/crypto_util_test.py::SSLSocketAndProbeSNITest::test_probe_ok
acme/_internal/tests/standalone_test.py::TLSALPN01ServerTest::test_bad_alpn
acme/_internal/tests/standalone_test.py::TLSALPN01ServerTest::test_challenge_certs
  /var/tmp/portage/app-crypt/certbot-4.0.0-r2/work/certbot-4.0.0-python3_11/install/usr/lib/python3.11/site-packages/acme/crypto_util.py:139: DeprecationWarning: Passing pyOpenSSL X509 objects is deprecated. You should use a cryptography.x509.Certificate instead.
    new_context.use_certificate(cert)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================= short test summary info ========================================================
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:78: Tests specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:99: Tests specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:107: Tests specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:69: Tests specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:96: Tests specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:39: Tests specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:127: Tests specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:54: Tests specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:102: Tests specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:248: Tests specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:235: Tests specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:223: Tests specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:331: Test specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:343: Test specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:320: Test specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:381: Test specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:429: Test specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:460: Test specific to Windows security
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:642: Tests specific to Windows
SKIPPED [1] certbot/_internal/tests/compat/filesystem_test.py:631: Tests specific to Windows
SKIPPED [1] certbot/_internal/tests/plugins/webroot_test.py:100: Test specific to Windows
SKIPPED [1] certbot/_internal/tests/plugins/webroot_test.py:118: Test specific to Windows
SKIPPED [1] certbot/_internal/tests/plugins/webroot_test.py:89: Test specific to Windows
FAILED certbot/_internal/tests/storage_test.py::RenewableCertTests::test_time_interval_judgments - OverflowError: timestamp out of range for platform time_t
======================================= 1 failed, 1243 passed, 23 skipped, 4 warnings in 50.09s ========================================
主要语言
Python
星标
33.4k
派生
3.5k
平均合并
4 天 2 小时
30 天内合并 PR
11

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

certbot/certbot 的其他 Issue

查看 certbot/certbot 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。