blob: 3c1575142577d4a0938b702adf4a7fcb944ac497 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import re
BEGIN_CERT = "-----BEGIN CERTIFICATE-----"
END_CERT = "-----END CERTIFICATE-----"
class PemTruststoreValidator:
def assert_pem_truststores_equal(self, result_pem_path, expected_pem_path):
result_certs = self.get_list_of_pem_certificates(result_pem_path)
expected_certs = self.get_list_of_pem_certificates(expected_pem_path)
result_certs.sort()
expected_certs.sort()
if len(result_certs) != len(expected_certs):
return False
return result_certs == expected_certs
def get_list_of_pem_certificates(self, path):
content = open(path, 'rb').read().decode("utf-8")
return re.findall(BEGIN_CERT + '(.+?)' + END_CERT, content, re.DOTALL)
|