Skip to content

Commit 65275bc

Browse files
committed
downgrade cryptography dep and pin to v42.0.8 for now
1 parent 86b074d commit 65275bc

File tree

10 files changed

+83
-101
lines changed

10 files changed

+83
-101
lines changed

client/certgrinder/certgrinder.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,17 +1148,15 @@ def check_ocsp(self) -> bool:
11481148
# parse the OCSP response
11491149
ocsp_response = self.load_ocsp_response(self.ocsp_response_path)
11501150

1151-
# consider the response produced_at_utc (rather than next_update_utc)
1152-
validity = ocsp_response.next_update_utc - ocsp_response.produced_at_utc
1153-
passed = (
1154-
datetime.datetime.now(datetime.timezone.utc) - ocsp_response.produced_at_utc
1155-
)
1151+
# consider the response produced_at (rather than next_update)
1152+
validity = ocsp_response.next_update - ocsp_response.produced_at
1153+
passed = datetime.datetime.now() - ocsp_response.produced_at
11561154
percent = (passed / validity) * 100
11571155
logger.debug(f"{percent} percent of OCSP response validity period has passed")
11581156

11591157
if percent > self.conf["ocsp-renew-threshold-percent"]:
11601158
logger.debug(
1161-
f"OCSP response is too old for keytype {self.keytype} for domainset: {self.domainset} ({round(percent,2)}% of the time between produced_at_utc and next_update_utc has passed, the limit is {self.conf['ocsp-renew-threshold-percent']}%), returning False"
1159+
f"OCSP response is too old for keytype {self.keytype} for domainset: {self.domainset} ({round(percent,2)}% of the time between produced_at and next_update has passed, the limit is {self.conf['ocsp-renew-threshold-percent']}%), returning False"
11621160
)
11631161
self.error = True
11641162
return False
@@ -1181,10 +1179,10 @@ def show_ocsp(self) -> None:
11811179
f"- Showing OCSP response for keytype {self.keytype} domain set: {self.domainset}"
11821180
)
11831181
logger.info(f"Certificate status: {ocsp_response.certificate_status}")
1184-
logger.info(f"This update: {ocsp_response.this_update_utc}")
1185-
logger.info(f"Produced at: {ocsp_response.produced_at_utc}")
1186-
logger.info(f"Next update: {ocsp_response.next_update_utc}")
1187-
logger.info(f"Revocation time: {ocsp_response.revocation_time_utc}")
1182+
logger.info(f"This update: {ocsp_response.this_update}")
1183+
logger.info(f"Produced at: {ocsp_response.produced_at}")
1184+
logger.info(f"Next update: {ocsp_response.next_update}")
1185+
logger.info(f"Revocation time: {ocsp_response.revocation_time}")
11881186
logger.info(f"Revocation reason: {ocsp_response.revocation_reason}")
11891187

11901188
@staticmethod
@@ -2146,7 +2144,7 @@ def get_parser() -> argparse.ArgumentParser:
21462144
type=int,
21472145
choices=range(0, 101),
21482146
metavar="OCSP-RENEW-THRESHOLD-PERCENT",
2149-
help="An integer between 0 and 100 specifying the amount of time in percent between ``produced_at_utc`` and ``next_update_utc`` which must have passed before an OCSP response is considered too old. Defaults to 50.",
2147+
help="An integer between 0 and 100 specifying the amount of time in percent between ``produced_at`` and ``next_update`` which must have passed before an OCSP response is considered too old. Defaults to 50.",
21502148
default=argparse.SUPPRESS,
21512149
)
21522150
parser.add_argument(

client/certgrinder/tests/test_certgrinder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def test_get_certificate(
310310
), "Exit code not 1 as expected with expired ocsp response"
311311
assert "OCSP response not found" not in caplog.text
312312
assert (
313-
"of the time between produced_at_utc and next_update_utc has passed, the limit is 0%"
313+
"of the time between produced_at and next_update has passed, the limit is 0%"
314314
in caplog.text
315315
)
316316
caplog.clear()
@@ -321,7 +321,7 @@ def test_get_certificate(
321321
assert E.type == SystemExit, f"Exit was not as expected, it was {E.type}"
322322
assert E.value.code == 0, "Exit code not 0 as expected with OK ocsp response"
323323
assert "OCSP response not found" not in caplog.text
324-
assert "was produced_at_utc more than" not in caplog.text
324+
assert "was produced_at more than" not in caplog.text
325325

326326
# we only need to test CAA once
327327
if certgrinderd_configfile[0] == "dns":

client/man/certgrinder.8

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
2727
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
2828
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
2929
..
30-
.TH "CERTGRINDER" "8" "Jan 10, 2025" "" "Certgrinder"
30+
.TH "CERTGRINDER" "8" "Jan 26, 2025" "" "Certgrinder"
3131
.SH NAME
3232
certgrinder \- Manpage for certgrinder
3333
.sp
@@ -350,7 +350,7 @@ Shown above is the \fBshow tlsa\fP subcommand in action. The value supplied shou
350350
The \fBversion\fP command is just a shortcut for \fB\-v\fP which shows the Certgrinder version and exits.
351351
.SH COMMAND LINE USAGE
352352
.sp
353-
Certgrinder version 0.19.3.dev21+g93b04c2.d20250105. See the manpage or ReadTheDocs for more info.
353+
Certgrinder version 0.20.1.dev0+g86b074d.d20250126. See the manpage or ReadTheDocs for more info.
354354

355355
.INDENT 0.0
356356
.INDENT 3.5
@@ -440,7 +440,7 @@ Run periodic command without delay. Equal to setting \-\-periodic\-sleep\-minute
440440
.B \-o, \-\-ocsp\-renew\-threshold\-percent
441441
Possible choices: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100
442442
.sp
443-
An integer between 0 and 100 specifying the amount of time in percent between \fBproduced_at_utc\fP and \fBnext_update_utc\fP which must have passed before an OCSP response is considered too old. Defaults to 50.
443+
An integer between 0 and 100 specifying the amount of time in percent between \fBproduced_at\fP and \fBnext_update\fP which must have passed before an OCSP response is considered too old. Defaults to 50.
444444
.TP
445445
.B \-\-path
446446
Tell certgrinder to use the specified directory for keys, CSRs and certificates. The directory must exist and be writeable by the user running certgrinder.

client/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ classifiers = [
1717
dependencies = [
1818
"dnspython == 2.7.0",
1919
"PyYAML == 6.0.1",
20-
"cryptography == 44.0.0",
20+
"cryptography == 42.0.8",
2121
"pid == 3.0.4",
2222
]
2323

conftest.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,8 @@ def selfsigned_certificate(known_private_key_2):
648648
.issuer_name(issuer)
649649
.public_key(known_private_key_2.public_key())
650650
.serial_number(x509.random_serial_number())
651-
.not_valid_before(datetime.datetime.now(datetime.timezone.utc))
652-
.not_valid_after(
653-
datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=10)
654-
)
651+
.not_valid_before(datetime.datetime.utcnow())
652+
.not_valid_after(datetime.datetime.utcnow() + datetime.timedelta(days=10))
655653
.add_extension(
656654
x509.SubjectAlternativeName(
657655
[x509.DNSName("example.com"), x509.DNSName("www.example.com")]
@@ -684,10 +682,8 @@ def signed_certificate(known_private_key, known_private_key_2):
684682
.issuer_name(issuer)
685683
.public_key(known_private_key.public_key())
686684
.serial_number(x509.random_serial_number())
687-
.not_valid_before(datetime.datetime.now(datetime.timezone.utc))
688-
.not_valid_after(
689-
datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=90)
690-
)
685+
.not_valid_before(datetime.datetime.utcnow())
686+
.not_valid_after(datetime.datetime.utcnow() + datetime.timedelta(days=90))
691687
.add_extension(
692688
x509.SubjectAlternativeName([x509.DNSName("example.com")]), critical=False
693689
)
@@ -721,10 +717,8 @@ def delegated_signer_certificate_not_signed_by_issuer(
721717
.issuer_name(issuer)
722718
.public_key(known_private_key_3.public_key())
723719
.serial_number(x509.random_serial_number())
724-
.not_valid_before(datetime.datetime.now(datetime.timezone.utc))
725-
.not_valid_after(
726-
datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=90)
727-
)
720+
.not_valid_before(datetime.datetime.utcnow())
721+
.not_valid_after(datetime.datetime.utcnow() + datetime.timedelta(days=90))
728722
.add_extension(
729723
x509.SubjectAlternativeName([x509.DNSName("delegatedresponder.example")]),
730724
critical=True,
@@ -761,10 +755,8 @@ def delegated_signer_certificate(known_private_key_3, known_private_key_2):
761755
.issuer_name(issuer)
762756
.public_key(known_private_key_3.public_key())
763757
.serial_number(x509.random_serial_number())
764-
.not_valid_before(datetime.datetime.now(datetime.timezone.utc))
765-
.not_valid_after(
766-
datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=90)
767-
)
758+
.not_valid_before(datetime.datetime.utcnow())
759+
.not_valid_after(datetime.datetime.utcnow() + datetime.timedelta(days=90))
768760
.add_extension(
769761
x509.SubjectAlternativeName([x509.DNSName("delegatedresponder.example")]),
770762
critical=True,
@@ -801,10 +793,8 @@ def delegated_signer_certificate_no_eku(known_private_key_3, known_private_key_2
801793
.issuer_name(issuer)
802794
.public_key(known_private_key_3.public_key())
803795
.serial_number(x509.random_serial_number())
804-
.not_valid_before(datetime.datetime.now(datetime.timezone.utc))
805-
.not_valid_after(
806-
datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=90)
807-
)
796+
.not_valid_before(datetime.datetime.utcnow())
797+
.not_valid_after(datetime.datetime.utcnow() + datetime.timedelta(days=90))
808798
.add_extension(
809799
x509.SubjectAlternativeName([x509.DNSName("delegatedresponder.example")]),
810800
critical=True,
@@ -837,10 +827,8 @@ def delegated_signer_certificate_no_ocsp_perm(known_private_key_3, known_private
837827
.issuer_name(issuer)
838828
.public_key(known_private_key_3.public_key())
839829
.serial_number(x509.random_serial_number())
840-
.not_valid_before(datetime.datetime.now(datetime.timezone.utc))
841-
.not_valid_after(
842-
datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=90)
843-
)
830+
.not_valid_before(datetime.datetime.utcnow())
831+
.not_valid_after(datetime.datetime.utcnow() + datetime.timedelta(days=90))
844832
.add_extension(
845833
x509.SubjectAlternativeName([x509.DNSName("delegatedresponder.example")]),
846834
critical=True,

docs/certgrinder-changelog.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ All notable changes to ``certgrinder`` will be documented in this file.
99

1010
This project adheres to `Semantic Versioning <http://semver.org/>`__.
1111

12+
Unreleased
13+
----------
14+
15+
Changed
16+
~~~~~~~
17+
18+
- Downgrade cryptography dependency and pin to 42.0.8 for now, pending upgrade of the FreeBSD ``security/py-cryptography`` port.
19+
1220

1321
v0.20.0 (10-jan-2025)
1422
---------------------

server/certgrinderd/certgrinderd.py

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import sys
1313
import tempfile
1414
import typing
15-
from datetime import datetime, timedelta, timezone
15+
from datetime import datetime, timedelta
1616
from importlib.metadata import PackageNotFoundError, version
1717
from pprint import pprint
1818

@@ -622,7 +622,7 @@ def get_ocsp_response(self, certpath: typing.Optional[str]) -> ocsp.OCSPResponse
622622
certpath: The path of the certificate chain to get OCSP response for (optional)
623623
624624
Returns:
625-
The OCSPResponse object
625+
The OCSPRequest object
626626
"""
627627
assert isinstance(self.conf["expected-chain-length"], int)
628628
chain = self.parse_certificate_chain(certpath)
@@ -692,12 +692,10 @@ def get_ocsp_response(self, certpath: typing.Optional[str]) -> ocsp.OCSPResponse
692692
logger.debug(
693693
f"Certificate status: {ocsp_response_object.certificate_status}"
694694
)
695-
logger.debug(f"This update: {ocsp_response_object.this_update_utc}")
696-
logger.debug(f"Produced at: {ocsp_response_object.produced_at_utc}")
697-
logger.debug(f"Next update: {ocsp_response_object.next_update_utc}")
698-
logger.debug(
699-
f"Revocation time: {ocsp_response_object.revocation_time_utc}"
700-
)
695+
logger.debug(f"This update: {ocsp_response_object.this_update}")
696+
logger.debug(f"Produced at: {ocsp_response_object.produced_at}")
697+
logger.debug(f"Next update: {ocsp_response_object.next_update}")
698+
logger.debug(f"Revocation time: {ocsp_response_object.revocation_time}")
701699
logger.debug(
702700
f"Revocation reason: {ocsp_response_object.revocation_reason}"
703701
)
@@ -809,28 +807,24 @@ def check_ocsp_response_timing(
809807
Returns:
810808
Boolean - True if all is well, False if a problem was found
811809
"""
812-
# check that this_update_utc is in the past
813-
if ocsp_response.this_update_utc > datetime.now(timezone.utc) + timedelta(
814-
minutes=5
815-
):
810+
# check that this_update is in the past
811+
if ocsp_response.this_update > datetime.utcnow() + timedelta(minutes=5):
816812
logger.error(
817-
f"The this_update_utc parameter of the OCSP response is in the future: {ocsp_response.this_update_utc}"
813+
f"The this_update parameter of the OCSP response is in the future: {ocsp_response.this_update}"
818814
)
819815
return False
820816

821-
# check that we have a next_update_utc attribute
822-
if not ocsp_response.next_update_utc:
817+
# check that we have a next_update attribute
818+
if not ocsp_response.next_update:
823819
logger.error(
824820
"OCSP response has no nextUpdate attribute. This violates RFC5019 2.2.4."
825821
)
826822
return False
827823

828-
# check that next_update_utc is in the future
829-
if ocsp_response.next_update_utc < datetime.now(timezone.utc) - timedelta(
830-
minutes=5
831-
):
824+
# check that next_update is in the future
825+
if ocsp_response.next_update < datetime.utcnow() - timedelta(minutes=5):
832826
logger.error(
833-
f"The next_update_utc parameter of the OCSP response is in the past: {ocsp_response.next_update_utc}"
827+
f"The next_update parameter of the OCSP response is in the past: {ocsp_response.this_update}"
834828
)
835829
return False
836830

@@ -1333,7 +1327,7 @@ def main(mockargs: typing.Optional[typing.List[str]] = None) -> None:
13331327
kwargs = {"prefix": "certgrinderd-temp-"}
13341328
if "temp-dir" in config and config["temp-dir"]:
13351329
kwargs["dir"] = config["temp-dir"]
1336-
tempdir = tempfile.TemporaryDirectory(**kwargs)
1330+
tempdir = tempfile.TemporaryDirectory(**kwargs) # type: ignore[call-overload]
13371331
config["temp-dir"] = tempdir.name
13381332

13391333
# instantiate Certgrinderd class

0 commit comments

Comments
 (0)