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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user