mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fail gracefully if the cert files cannot be created
This commit is contained in:
parent
482043aed6
commit
7fc8e2993a
1 changed files with 7 additions and 2 deletions
|
@ -265,18 +265,23 @@ def create_cert_files():
|
||||||
'common-name': fqdn,
|
'common-name': fqdn,
|
||||||
})
|
})
|
||||||
fp.close()
|
fp.close()
|
||||||
os.system(
|
error = os.system(
|
||||||
"openssl req -batch -new -x509 -days 10 -nodes -config %s "
|
"openssl req -batch -new -x509 -days 10 -nodes -config %s "
|
||||||
"-keyout \"%s\" -out \"%s\" > /dev/null < /dev/null 2>&1" %
|
"-keyout \"%s\" -out \"%s\" > /dev/null < /dev/null 2>&1" %
|
||||||
(conffile, crtfile, crtfile))
|
(conffile, crtfile, crtfile))
|
||||||
# now we have a self-signed server cert in crtfile
|
# now we have a self-signed server cert in crtfile
|
||||||
os.unlink(conffile)
|
os.unlink(conffile)
|
||||||
|
if error or not os.path.exists(crtfile) or os.path.getsize(crtfile) == 0:
|
||||||
|
raise test_support.TestFailed(
|
||||||
|
"Unable to create certificate for test %d." % error)
|
||||||
|
return d, crtfile
|
||||||
|
|
||||||
|
# XXX(nnorwitz): should this code be removed now?
|
||||||
#sf_certfile = os.path.join(d, "sourceforge-imap.pem")
|
#sf_certfile = os.path.join(d, "sourceforge-imap.pem")
|
||||||
#sf_cert = ssl.fetch_server_certificate('pop.gmail.com', 995)
|
#sf_cert = ssl.fetch_server_certificate('pop.gmail.com', 995)
|
||||||
#open(sf_certfile, 'w').write(sf_cert)
|
#open(sf_certfile, 'w').write(sf_cert)
|
||||||
#return d, crtfile, sf_certfile
|
#return d, crtfile, sf_certfile
|
||||||
# sys.stderr.write(open(crtfile, 'r').read() + '\n')
|
# sys.stderr.write(open(crtfile, 'r').read() + '\n')
|
||||||
return d, crtfile
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
if skip_expected:
|
if skip_expected:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue