diff -r f727edff50bd -r 52e8eec3014c src/tests/pkg5unittest.py --- a/src/tests/pkg5unittest.py Tue Mar 08 11:12:06 2016 -0800 +++ b/src/tests/pkg5unittest.py Wed Mar 09 11:27:23 2016 -0800 @@ -67,6 +67,9 @@ import traceback import types +from cryptography import x509 +from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives import serialization from imp import reload from six.moves import configparser, http_client from six.moves.urllib.error import HTTPError, URLError @@ -79,7 +82,6 @@ import pkg.client.publisher as publisher import pkg.portable as portable import pkg.server.repository as sr -import M2Crypto as m2 from pkg.client.debugvalues import DebugValues @@ -922,9 +924,12 @@ @staticmethod def calc_pem_hash(pth): - # Find the hash of pem representation the file. - cert = m2.X509.load_cert(pth) - return hashlib.sha1(cert.as_pem()).hexdigest() + """Find the hash of pem representation the file.""" + with open(pth) as f: + cert = x509.load_pem_x509_certificate( + f.read(), default_backend()) + return hashlib.sha1( + cert.public_bytes(serialization.Encoding.PEM)).hexdigest() def reduceSpaces(self, string): """Reduce runs of spaces down to a single space."""