diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-26 18:50:39 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-26 18:50:39 (GMT) |
commit | 7fc8e2993ae341d789c2401c145f253f9dfdaff4 (patch) | |
tree | d31de961b1d0349b647c1564176b077d557594fe /Lib | |
parent | 482043aed6988c7f32810099e4286bc1e6ab02b1 (diff) | |
download | cpython-7fc8e2993ae341d789c2401c145f253f9dfdaff4.zip cpython-7fc8e2993ae341d789c2401c145f253f9dfdaff4.tar.gz cpython-7fc8e2993ae341d789c2401c145f253f9dfdaff4.tar.bz2 |
Fail gracefully if the cert files cannot be created
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_ssl.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index c73058e..4f9e47c 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -265,18 +265,23 @@ def create_cert_files(): 'common-name': fqdn, }) fp.close() - os.system( + error = os.system( "openssl req -batch -new -x509 -days 10 -nodes -config %s " "-keyout \"%s\" -out \"%s\" > /dev/null < /dev/null 2>&1" % (conffile, crtfile, crtfile)) # now we have a self-signed server cert in crtfile 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_cert = ssl.fetch_server_certificate('pop.gmail.com', 995) #open(sf_certfile, 'w').write(sf_cert) #return d, crtfile, sf_certfile # sys.stderr.write(open(crtfile, 'r').read() + '\n') - return d, crtfile def test_main(): if skip_expected: |