#NEWLINE# def generate_adhoc_ssl_context( ) : #NEWLINE# #INDENT# 'Generates an adhoc SSL context for the development server.' #NEWLINE# crypto = _get_openssl_crypto_module ( ) #NEWLINE# import tempfile #NEWLINE# import atexit #NEWLINE# ( cert , pkey ) = generate_adhoc_ssl_pair ( ) #NEWLINE# ( cert_handle , cert_file ) = tempfile . mkstemp ( ) #NEWLINE# ( pkey_handle , pkey_file ) = tempfile . mkstemp ( ) #NEWLINE# atexit . register ( os . remove , pkey_file ) #NEWLINE# atexit . register ( os . remove , cert_file ) #NEWLINE# os . write ( cert_handle , crypto . dump_certificate ( pkey . FILETYPE_PEM , cert ) ) #NEWLINE# os . write ( pkey_handle , crypto . dump_privatekey ( crypto . FILETYPE_PEM , pkey ) ) #NEWLINE# os . close ( cert_handle ) #NEWLINE# os . close ( pkey_handle ) #NEWLINE# ctx = load_ssl_context ( cert_file , pkey_file ) #NEWLINE# return ctx