Do not check a pinned certificate's dates

A pin trusts one exact certificate, so an expired one or an engine clock
that is off no longer locks a device out (X509_V_FLAG_NO_CHECK_TIME).
This commit is contained in:
2026-10-07 10:11:08 +02:00
parent cd6f8fec55
commit d482b32970
3 changed files with 117 additions and 0 deletions
+4
View File
@@ -83,6 +83,10 @@ def context_for(pem: str) -> ssl.SSLContext:
context.check_hostname = False
# The pinned certificate is the trust anchor, not a chain up to a root.
context.verify_flags |= ssl.VERIFY_X509_PARTIAL_CHAIN
# X509_V_FLAG_NO_CHECK_TIME, which `ssl` has no name for. A pin trusts one
# exact certificate, so its dates add nothing, and a device's certificate
# that expired, or a clock that is off, would otherwise lock it out.
context.verify_flags |= 0x200000
context.load_verify_locations(cadata=pem)
return context