cryptography has deprecated serial in favor of serial_number

Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Christian Heimes 2017-02-10 14:20:22 +01:00 committed by Martin Basti
parent a33b25dea9
commit 3d9bec2e87
6 changed files with 12 additions and 12 deletions

View File

@ -33,7 +33,7 @@ def _parse_cert(dercert):
cert = x509.load_certificate(dercert, x509.DER)
subject = DN(cert.subject)
issuer = DN(cert.issuer)
serial_number = cert.serial
serial_number = cert.serial_number
public_key_info = x509.get_der_public_key_info(dercert, x509.DER)
except (ValueError, PyAsn1Error) as e:
raise ValueError("failed to decode certificate: %s" % e)

View File

@ -702,7 +702,7 @@ class CAInstance(DogtagInstance):
userstate=["1"],
userCertificate=[cert_data],
description=['2;%s;%s;%s' % (
cert.serial,
cert.serial_number,
DN(self.ca_subject),
DN(('CN', 'IPA RA'), self.subject_base))])
conn.add_entry(entry)
@ -1437,7 +1437,7 @@ def update_authority_entry(dercert):
def make_entry(dercert, entry):
cert = x509.load_certificate(dercert, datatype=x509.DER)
entry['authoritySerial'] = cert.serial
entry['authoritySerial'] = cert.serial_number
return entry
return __update_entry_from_cert(make_filter, make_entry, dercert)

View File

@ -387,7 +387,7 @@ class BaseCertObject(Object):
cert = x509.load_certificate(obj['certificate'])
obj['subject'] = DN(cert.subject)
obj['issuer'] = DN(cert.issuer)
obj['serial_number'] = cert.serial
obj['serial_number'] = cert.serial_number
obj['valid_not_before'] = x509.format_datetime(
cert.not_valid_before)
obj['valid_not_after'] = x509.format_datetime(
@ -1257,7 +1257,7 @@ class cert_find(Search, CertMethod):
raise
return (DN(cert_obj.issuer), cert_obj.serial)
return (DN(cert_obj.issuer), cert_obj.serial_number)
def _get_cert_obj(self, cert, all, raw, pkey_only):
obj = {'certificate': base64.b64encode(cert).decode('ascii')}

View File

@ -268,8 +268,8 @@ def set_certificate_attrs(entry_attrs):
cert = x509.normalize_certificate(cert)
cert = x509.load_certificate(cert, datatype=x509.DER)
entry_attrs['subject'] = unicode(DN(cert.subject))
entry_attrs['serial_number'] = unicode(cert.serial)
entry_attrs['serial_number_hex'] = u'0x%X' % cert.serial
entry_attrs['serial_number'] = unicode(cert.serial_number)
entry_attrs['serial_number_hex'] = u'0x%X' % cert.serial_number
entry_attrs['issuer'] = unicode(DN(cert.issuer))
entry_attrs['valid_not_before'] = x509.format_datetime(
cert.not_valid_before)

View File

@ -116,6 +116,6 @@ class test_x509(object):
assert DN(cert.subject) == DN(('CN', 'ipa.example.com'), ('O', 'IPA'))
assert DN(cert.issuer) == DN(('CN', 'IPA Test Certificate Authority'))
assert cert.serial == 1093
assert cert.serial_number == 1093
assert cert.not_valid_before == not_before
assert cert.not_valid_after == not_after

View File

@ -80,7 +80,7 @@ class test_ldap(object):
entry_attrs = self.conn.get_entry(self.dn, ['usercertificate'])
cert = entry_attrs.get('usercertificate')
cert = cert[0]
serial = x509.load_certificate(cert, x509.DER).serial
serial = x509.load_certificate(cert, x509.DER).serial_number
assert serial is not None
def test_simple(self):
@ -99,7 +99,7 @@ class test_ldap(object):
entry_attrs = self.conn.get_entry(self.dn, ['usercertificate'])
cert = entry_attrs.get('usercertificate')
cert = cert[0]
serial = x509.load_certificate(cert, x509.DER).serial
serial = x509.load_certificate(cert, x509.DER).serial_number
assert serial is not None
def test_Backend(self):
@ -127,7 +127,7 @@ class test_ldap(object):
entry_attrs = result['result']
cert = entry_attrs.get('usercertificate')
cert = cert[0]
serial = x509.load_certificate(cert, x509.DER).serial
serial = x509.load_certificate(cert, x509.DER).serial_number
assert serial is not None
def test_autobind(self):
@ -143,7 +143,7 @@ class test_ldap(object):
entry_attrs = self.conn.get_entry(self.dn, ['usercertificate'])
cert = entry_attrs.get('usercertificate')
cert = cert[0]
serial = x509.load_certificate(cert, x509.DER).serial
serial = x509.load_certificate(cert, x509.DER).serial_number
assert serial is not None