in src/local_gpu_verifier/src/verifier/nvml/nvmlHandlerTest.py [0:0]
def extract_cert_chain(self, bin_cert_chain_data):
try:
assert type(bin_cert_chain_data) is bytes
PEM_CERT_END_DELIMITER = '-----END CERTIFICATE-----'
start_index = 0
end_index = None
# length of \n is 1
length_of_new_line = 1
str_data = bin_cert_chain_data.decode()
cert_obj_list = list()
for itr in re.finditer(PEM_CERT_END_DELIMITER, str_data):
end_index = itr.start()
cert_obj_list.append(crypto.load_certificate(crypto.FILETYPE_PEM, \
str_data[start_index : end_index + len(PEM_CERT_END_DELIMITER)]))
start_index = end_index + len(PEM_CERT_END_DELIMITER) + length_of_new_line
if len(str_data) < start_index:
break
return cert_obj_list
except Exception as err:
raise CertExtractionError("\tSomething went wrong while extracting the individual certificates from the certificate chain.\n\tQuitting now.")