#NEWLINE# def make_ssl_devcert( base_path , host = None , cn = None ) : #NEWLINE# #INDENT# "Creates an SSL key for development.  This should be used instead of\n    the ``'adhoc'`` key which generates a new cert on each server start.\n    It accepts a path for where it should store the key and cert and\n    either a host or CN.  If a host is given it will use the CN\n    ``*.host/CN=host``.\n\n    For more information see :func:`run_simple`.\n\n    .. versionadded:: 0.9\n\n    :param base_path: the path to the certificate and key.  The extension\n                      ``.crt`` is added for the certificate, ``.key`` is\n                      added for the key.\n    :param host: the name of the host.  This can be used as an alternative\n                 for the `cn`.\n    :param cn: the `CN` to use.\n    " #NEWLINE# from OpenSSL import crypto #NEWLINE# if ( host is not None ) : #NEWLINE# #INDENT# cn = ( '*.%s/CN=%s' % ( host , base_path ) ) #NEWLINE# #UNINDENT# ( cert , pkey ) = generate_adhoc_ssl_pair ( cn = cn ) #NEWLINE# cert_file = ( base_path + '.crt' ) #NEWLINE# pkey_file = ( base_path + '.key' ) #NEWLINE# with open ( cert_file , 'wb' ) as f : #NEWLINE# #INDENT# f . write ( crypto . dump_certificate ( crypto . FILETYPE_PEM , cert ) ) #NEWLINE# #UNINDENT# with open ( pkey_file , 'wb' ) as f : #NEWLINE# #INDENT# f . write ( crypto . dump_privatekey ( crypto . FILETYPE_PEM , pkey ) ) #NEWLINE# #UNINDENT# return ( cert_file , pkey_file )