Skip to content

Commit 20b2516

Browse files
authored
feat: short-lived certs always pass OCSP checks (#42)
Firefox skips OCSP checks for certs younger than the number of days specified in security.pki.cert_short_lifetime_in_days (10 by default), which makes sense because OCSP stapling is redundant for short-lived certs. Revocation is only applicable to long-lived certs with lifetimes measured in weeks or longer. Ready now exhibits the same behavior.
1 parent bfce67b commit 20b2516

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

ready/checks/ssl.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,23 @@ def check_ssl_certificate_should_provide_ocsp_must_staple(responses, **kwargs):
259259
loaded = x509.load_der_x509_certificate(certificate)
260260

261261
has_must_staple_extension = False
262-
for extension in loaded.extensions:
263-
# see https://github.com/sesh/ready/issues/15 for details
264-
if extension.oid.dotted_string == "1.3.6.1.5.5.7.1.24":
265-
has_must_staple_extension = True
262+
msg = "missing extension"
263+
264+
lifetime_days = (loaded.not_valid_after - loaded.not_valid_before).days
265+
if lifetime_days < 10:
266+
has_must_staple_exension = True
267+
msg = "certificate is short-lived; missing extension"
268+
269+
else:
270+
for extension in loaded.extensions:
271+
# see https://github.com/sesh/ready/issues/15 for details
272+
if extension.oid.dotted_string == "1.3.6.1.5.5.7.1.24":
273+
has_must_staple_extension = True
274+
msg = "includes extension"
266275

267276
return result(
268277
has_must_staple_extension,
269-
f"SSL certificate should provide OCSP must-staple ({'missing' if not has_must_staple_extension else 'includes'} extension)",
278+
f"Long-lived SSL certificate should provide OCSP must-staple ({msg})",
270279
"ssl_ocsp_must_staple",
271280
warn_on_fail=True,
272281
**kwargs,

0 commit comments

Comments
 (0)