equal
deleted
inserted
replaced
65 import textwrap |
65 import textwrap |
66 import threading |
66 import threading |
67 import traceback |
67 import traceback |
68 import types |
68 import types |
69 |
69 |
|
70 from cryptography import x509 |
|
71 from cryptography.hazmat.backends import default_backend |
|
72 from cryptography.hazmat.primitives import serialization |
70 from imp import reload |
73 from imp import reload |
71 from six.moves import configparser, http_client |
74 from six.moves import configparser, http_client |
72 from six.moves.urllib.error import HTTPError, URLError |
75 from six.moves.urllib.error import HTTPError, URLError |
73 from six.moves.urllib.parse import urljoin |
76 from six.moves.urllib.parse import urljoin |
74 from six.moves.urllib.request import urlopen |
77 from six.moves.urllib.request import urlopen |
77 import pkg.client.api_errors as apx |
80 import pkg.client.api_errors as apx |
78 import pkg.misc as misc |
81 import pkg.misc as misc |
79 import pkg.client.publisher as publisher |
82 import pkg.client.publisher as publisher |
80 import pkg.portable as portable |
83 import pkg.portable as portable |
81 import pkg.server.repository as sr |
84 import pkg.server.repository as sr |
82 import M2Crypto as m2 |
|
83 |
85 |
84 from pkg.client.debugvalues import DebugValues |
86 from pkg.client.debugvalues import DebugValues |
85 |
87 |
86 EmptyI = tuple() |
88 EmptyI = tuple() |
87 EmptyDict = dict() |
89 EmptyDict = dict() |
920 self.debugfilecreate(content, t_path) |
922 self.debugfilecreate(content, t_path) |
921 return t_path |
923 return t_path |
922 |
924 |
923 @staticmethod |
925 @staticmethod |
924 def calc_pem_hash(pth): |
926 def calc_pem_hash(pth): |
925 # Find the hash of pem representation the file. |
927 """Find the hash of pem representation the file.""" |
926 cert = m2.X509.load_cert(pth) |
928 with open(pth) as f: |
927 return hashlib.sha1(cert.as_pem()).hexdigest() |
929 cert = x509.load_pem_x509_certificate( |
|
930 f.read(), default_backend()) |
|
931 return hashlib.sha1( |
|
932 cert.public_bytes(serialization.Encoding.PEM)).hexdigest() |
928 |
933 |
929 def reduceSpaces(self, string): |
934 def reduceSpaces(self, string): |
930 """Reduce runs of spaces down to a single space.""" |
935 """Reduce runs of spaces down to a single space.""" |
931 return re.sub(" +", " ", string) |
936 return re.sub(" +", " ", string) |
932 |
937 |