Convert valid_date to bytes for conversion (#40872)

Fixes: #40523

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2018-06-11 19:23:53 +05:30 committed by GitHub
parent 1998707eda
commit b310b278be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -661,7 +661,7 @@ class AssertOnlyCertificate(Certificate):
def _validate_valid_at():
if self.valid_at:
if not (self.valid_at >= self.cert.get_notBefore() and self.valid_at <= self.cert.get_notAfter()):
if not (self.cert.get_notBefore() <= self.valid_at <= self.cert.get_notAfter()):
self.message.append(
'Certificate is not valid for the specified date (%s) - notBefore: %s - notAfter: %s' % (self.valid_at,
self.cert.get_notBefore(),
@ -680,8 +680,8 @@ class AssertOnlyCertificate(Certificate):
def _validate_valid_in():
if self.valid_in:
valid_in_date = datetime.datetime.utcnow() + datetime.timedelta(seconds=self.valid_in)
valid_in_date = valid_in_date.strftime('%Y%m%d%H%M%SZ')
if not (valid_in_date >= self.cert.get_notBefore() and valid_in_date <= self.cert.get_notAfter()):
valid_in_date = to_bytes(valid_in_date.strftime('%Y%m%d%H%M%SZ'), errors='surrogate_or_strict')
if not (self.cert.get_notBefore() <= valid_in_date <= self.cert.get_notAfter()):
self.message.append(
'Certificate is not valid in %s seconds from now (%s) - notBefore: %s - notAfter: %s' % (self.valid_in,
valid_in_date,