Back to index

python3.2  3.2.2
Functions | Variables
test.make_ssl_certs Namespace Reference

Functions

def make_cert_key

Variables

string req_template
tuple here = os.path.abspath(os.path.dirname(__file__))

Detailed Description

Make the custom certificate and private key files used by test_ssl
and friends.

Function Documentation

Definition at line 27 of file make_ssl_certs.py.

00027 
00028 def make_cert_key(hostname):
00029     tempnames = []
00030     for i in range(3):
00031         with tempfile.NamedTemporaryFile(delete=False) as f:
00032             tempnames.append(f.name)
00033     req_file, cert_file, key_file = tempnames
00034     try:
00035         with open(req_file, 'w') as f:
00036             f.write(req_template.format(hostname=hostname))
00037         args = ['req', '-new', '-days', '3650', '-nodes', '-x509',
00038                 '-newkey', 'rsa:1024', '-keyout', key_file,
00039                 '-out', cert_file, '-config', req_file]
00040         check_call(['openssl'] + args)
00041         with open(cert_file, 'r') as f:
00042             cert = f.read()
00043         with open(key_file, 'r') as f:
00044             key = f.read()
00045         return cert, key
00046     finally:
00047         for name in tempnames:
00048             os.remove(name)
00049 

Here is the call graph for this function:


Variable Documentation

tuple test.make_ssl_certs.here = os.path.abspath(os.path.dirname(__file__))

Definition at line 25 of file make_ssl_certs.py.

Initial value:
00001 """
00002     [req]
00003     distinguished_name     = req_distinguished_name
00004     x509_extensions        = req_x509_extensions
00005     prompt                 = no
00006 
00007     [req_distinguished_name]
00008     C                      = XY
00009     L                      = Castle Anthrax
00010     O                      = Python Software Foundation
00011     CN                     = {hostname}
00012 
00013     [req_x509_extensions]
00014     subjectAltName         = DNS:{hostname}
00015     """

Definition at line 9 of file make_ssl_certs.py.