Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Unified Diff: net/data/verify_certificate_chain_unittest/common.py

Issue 2036033002: Add CertIssuerSourceAia: authorityInfoAccess fetching for CertPathBuilder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert-parsing-path-building
Patch Set: remove orphaned kw_args change, remove g_cur_path_id change from this cl Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/data/update_net_gypi.py ('k') | net/net.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/data/verify_certificate_chain_unittest/common.py
diff --git a/net/data/verify_certificate_chain_unittest/common.py b/net/data/verify_certificate_chain_unittest/common.py
index 5a6c3ec97e0a13b72062cebba3ae510d176c1df0..60fe43ee8dc1f7ed65debbe3182f1ced04539fec 100755
--- a/net/data/verify_certificate_chain_unittest/common.py
+++ b/net/data/verify_certificate_chain_unittest/common.py
@@ -78,6 +78,9 @@ class Certificate(object):
self.name = name
self.path_id = GetUniquePathId(name)
+ # If specified, use the key from this path instead of generating a new one.
+ self.key_path = None
+
# The issuer is also a Certificate object. Passing |None| means it is a
# self-signed certificate.
self.issuer = issuer
@@ -132,6 +135,7 @@ class Certificate(object):
def generate_rsa_key(self, size_bits):
"""Generates an RSA private key for the certificate."""
+ assert self.key_path is None
subprocess.check_call(
['openssl', 'genrsa', '-out', self.get_key_path(), str(size_bits)])
@@ -139,6 +143,7 @@ class Certificate(object):
def generate_ec_key(self, named_curve):
"""Generates an EC private key for the certificate. |named_curve| can be
something like secp384r1"""
+ assert self.key_path is None
subprocess.check_call(
['openssl', 'ecparam', '-out', self.get_key_path(),
'-name', named_curve, '-genkey'])
@@ -166,7 +171,16 @@ class Certificate(object):
return os.path.join(g_out_dir, '%s%s' % (self.path_id, suffix))
+ def set_key_path(self, path):
+ """Uses the key from the given path instead of generating a new one."""
+ self.key_path = path
+ section = self.config.get_section('root_ca')
+ section.set_property('private_key', self.get_key_path())
+
+
def get_key_path(self):
+ if self.key_path is not None:
+ return self.key_path
return self.get_path('.key')
@@ -351,7 +365,8 @@ def data_to_pem(block_header, block_data):
base64.b64encode(block_data), block_header)
-def write_test_file(description, chain, trusted_certs, utc_time, verify_result):
+def write_test_file(description, chain, trusted_certs, utc_time, verify_result,
+ out_pem=None):
"""Writes a test file that contains all the inputs necessary to run a
verification on a certificate chain"""
@@ -374,7 +389,7 @@ def write_test_file(description, chain, trusted_certs, utc_time, verify_result):
verify_result_string = 'SUCCESS' if verify_result else 'FAIL'
test_data += '\n' + data_to_pem('VERIFY_RESULT', verify_result_string)
- write_string_to_file(test_data, g_out_pem)
+ write_string_to_file(test_data, out_pem if out_pem else g_out_pem)
def write_string_to_file(data, path):
« no previous file with comments | « net/data/update_net_gypi.py ('k') | net/net.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698