Skip to content

Commit

Permalink
Use openssl CLI tool instead of text manipulation.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Oct 4, 2024
1 parent 2265e43 commit 021af09
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Lib/test/certdata/cert3.pem

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 1 addition & 20 deletions Lib/test/certdata/make_ssl_certs.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,23 +231,6 @@ def write_cert_reference(path):
print(refdata, file=f)


def extract_cert(pem_cert, index):
result = []
active = False
for line in pem_cert.splitlines():
match = active
if line == '-----BEGIN CERTIFICATE-----':
if index == 0:
active = True
match = True
index -= 1
elif line == '-----END CERTIFICATE-----':
active = False
if match:
result.append(line)
return '\n'.join(result) + '\n'


if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Make the custom certificate and private key files used by test_ssl and friends.')
parser.add_argument('--days', default=days_default)
Expand Down Expand Up @@ -283,9 +266,7 @@ def extract_cert(pem_cert, index):
f.write(key)
f.write(cert)

cert = extract_cert(cert, 0)
with open('cert3.pem', 'w') as f:
f.write(cert)
check_call(['openssl', 'x509', '-outform', 'pem', '-in', 'keycert3.pem', '-out', 'cert3.pem'])

cert, key = make_cert_key(cmdlineargs, 'fakehostname', sign=True)
with open('keycert4.pem', 'w') as f:
Expand Down

0 comments on commit 021af09

Please sign in to comment.