| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Set of helpers to generate signed X.509v3 certificates. | 6 """Set of helpers to generate signed X.509v3 certificates. |
| 7 | 7 |
| 8 This works by shelling out calls to the 'openssl req' and 'openssl ca' | 8 This works by shelling out calls to the 'openssl req' and 'openssl ca' |
| 9 commands, and passing the appropriate command line flags and configuration file | 9 commands, and passing the appropriate command line flags and configuration file |
| 10 (.cnf). | 10 (.cnf). |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 # Write the certificate chain to the output file. | 446 # Write the certificate chain to the output file. |
| 447 for cert in chain: | 447 for cert in chain: |
| 448 test_data += '\n' + cert.get_cert_pem() | 448 test_data += '\n' + cert.get_cert_pem() |
| 449 | 449 |
| 450 test_data += '\n' + trust_anchor.get_pem() | 450 test_data += '\n' + trust_anchor.get_pem() |
| 451 test_data += '\n' + text_data_to_pem('TIME', utc_time) | 451 test_data += '\n' + text_data_to_pem('TIME', utc_time) |
| 452 | 452 |
| 453 verify_result_string = 'SUCCESS' if verify_result else 'FAIL' | 453 verify_result_string = 'SUCCESS' if verify_result else 'FAIL' |
| 454 test_data += '\n' + text_data_to_pem('VERIFY_RESULT', verify_result_string) | 454 test_data += '\n' + text_data_to_pem('VERIFY_RESULT', verify_result_string) |
| 455 | 455 |
| 456 # TODO(eroman): Make the consumer pass errors as a string. | |
| 457 if errors is not None: | 456 if errors is not None: |
| 458 test_data += '\n' + text_data_to_pem('ERRORS', '\n'.join(errors)) | 457 test_data += '\n' + text_data_to_pem('ERRORS', errors) |
| 459 | 458 |
| 460 write_string_to_file(test_data, out_pem if out_pem else g_out_pem) | 459 write_string_to_file(test_data, out_pem if out_pem else g_out_pem) |
| 461 | 460 |
| 462 | 461 |
| 463 def write_string_to_file(data, path): | 462 def write_string_to_file(data, path): |
| 464 with open(path, 'w') as f: | 463 with open(path, 'w') as f: |
| 465 f.write(data) | 464 f.write(data) |
| 466 | 465 |
| 467 | 466 |
| 468 def init(invoking_script_path): | 467 def init(invoking_script_path): |
| (...skipping 28 matching lines...) Expand all Loading... |
| 497 | 496 |
| 498 | 497 |
| 499 def create_intermediate_certificate(name, issuer): | 498 def create_intermediate_certificate(name, issuer): |
| 500 return Certificate(name, TYPE_CA, issuer) | 499 return Certificate(name, TYPE_CA, issuer) |
| 501 | 500 |
| 502 | 501 |
| 503 def create_end_entity_certificate(name, issuer): | 502 def create_end_entity_certificate(name, issuer): |
| 504 return Certificate(name, TYPE_END_ENTITY, issuer) | 503 return Certificate(name, TYPE_END_ENTITY, issuer) |
| 505 | 504 |
| 506 init(sys.argv[0]) | 505 init(sys.argv[0]) |
| OLD | NEW |