<s> from __future__ import unicode_literals , division , absolute_import , print_function <EOL> from ctypes . util import find_library <EOL> from ctypes import CDLL , CFUNCTYPE , POINTER , c_void_p , c_char_p , c_int , c_size_t , c_long <EOL> from . . _ffi import LibraryNotFoundError , FFIEngineError <EOL> __all__ = [ <EOL> '<STR_LIT>' , <EOL> ] <EOL> libssl_path = find_library ( '<STR_LIT>' ) <EOL> if not libssl_path : <EOL> raise LibraryNotFoundError ( '<STR_LIT>' ) <EOL> libssl = CDLL ( libssl_path , use_errno = True ) <EOL> P_SSL_METHOD = POINTER ( c_void_p ) <EOL> P_SSL_CTX = POINTER ( c_void_p ) <EOL> P_SSL_SESSION = POINTER ( c_void_p ) <EOL> P_SSL = POINTER ( c_void_p ) <EOL> P_BIO_METHOD = POINTER ( c_void_p ) <EOL> P_BIO = POINTER ( c_void_p ) <EOL> X509 = c_void_p <EOL> P_X509 = POINTER ( X509 ) <EOL> P_X509_STORE = POINTER ( c_void_p ) <EOL> P_X509_STORE_CTX = POINTER ( c_void_p ) <EOL> _STACK = c_void_p <EOL> P_STACK = POINTER ( _STACK ) <EOL> try : <EOL> stack_cmp_func = CFUNCTYPE ( c_int , c_void_p , c_void_p ) <EOL> setattr ( libssl , '<STR_LIT>' , stack_cmp_func ) <EOL> libssl . sk_num . argtypes = [ P_STACK ] <EOL> libssl . sk_num . restype = c_int <EOL> libssl . sk_value . argtypes = [ P_STACK , c_int ] <EOL> libssl . sk_value . restype = P_X509 <EOL> libssl . SSL_library_init . argtypes = [ ] <EOL> libssl . SSL_library_init . restype = c_int <EOL> libssl . OPENSSL_add_all_algorithms_noconf . argtypes = [ ] <EOL> libssl . OPENSSL_add_all_algorithms_noconf . restype = None <EOL> libssl . BIO_s_mem . argtypes = [ ] <EOL> libssl . BIO_s_mem . restype = P_BIO_METHOD <EOL> libssl . BIO_new . argtypes = [ <EOL> P_BIO_METHOD <EOL> ] <EOL> libssl . BIO_new . restype = P_BIO <EOL> libssl . BIO_free . argtypes = [ <EOL> P_BIO <EOL> ] <EOL> libssl . BIO_free . restype = c_int <EOL> libssl . BIO_read . argtypes = [ <EOL> P_BIO , <EOL> c_char_p , <EOL> c_int <EOL> ] <EOL> libssl . BIO_read . restype = c_int <EOL> libssl . BIO_write . argtypes = [ <EOL> P_BIO , <EOL> c_char_p , <EOL> c_int <EOL> ] <EOL> libssl . BIO_write . restype = c_int <EOL> libssl . BIO_ctrl_pending . argtypes = [ <EOL> P_BIO <EOL> ] <EOL> libssl . BIO_ctrl_pending . restype = c_size_t <EOL> libssl . SSLv23_method . argtypes = [ ] <EOL> libssl . SSLv23_method . restype = P_SSL_METHOD <EOL> libssl . SSL_CTX_new . argtypes = [ <EOL> P_SSL_METHOD <EOL> ] <EOL> libssl . SSL_CTX_new . restype = P_SSL_CTX <EOL> libssl . SSL_CTX_set_timeout . argtypes = [ <EOL> P_SSL_CTX , <EOL> c_long <EOL> ] <EOL> libssl . SSL_CTX_set_timeout . restype = c_long <EOL> verify_callback = CFUNCTYPE ( c_int , c_int , P_X509_STORE_CTX ) <EOL> setattr ( libssl , '<STR_LIT>' , verify_callback ) <EOL> libssl . SSL_CTX_set_verify . argtypes = [ <EOL> P_SSL_CTX , <EOL> c_int , <EOL> POINTER ( verify_callback ) <EOL> ] <EOL> libssl . SSL_CTX_set_verify . restype = None <EOL> libssl . SSL_CTX_set_default_verify_paths . argtypes = [ <EOL> P_SSL_CTX <EOL> ] <EOL> libssl . SSL_CTX_set_default_verify_paths . restype = c_int <EOL> libssl . SSL_CTX_load_verify_locations . argtypes = [ <EOL> P_SSL_CTX , <EOL> c_char_p , <EOL> c_char_p <EOL> ] <EOL> libssl . SSL_CTX_load_verify_locations . restype = c_int <EOL> libssl . SSL_get_verify_result . argtypes = [ <EOL> P_SSL <EOL> ] <EOL> libssl . SSL_get_verify_result . restype = c_long <EOL> libssl . SSL_CTX_get_cert_store . argtypes = [ <EOL> P_SSL_CTX <EOL> ] <EOL> libssl . SSL_CTX_get_cert_store . restype = P_X509_STORE <EOL> libssl . X509_STORE_add_cert . argtypes = [ <EOL> P_X509_STORE , <EOL> P_X509 <EOL> ] <EOL> libssl . X509_STORE_add_cert . restype = c_int <EOL> libssl . SSL_CTX_set_cipher_list . argtypes = [ <EOL> P_SSL_CTX , <EOL> c_char_p <EOL> ] <EOL> libssl . SSL_CTX_set_cipher_list . restype = c_int <EOL> libssl . SSL_CTX_ctrl . arg_types = [ <EOL> P_SSL_CTX , <EOL> c_int , <EOL> c_long , <EOL> c_void_p <EOL> ] <EOL> libssl . SSL_CTX_ctrl . restype = c_long <EOL> libssl . SSL_CTX_free . argtypes = [ <EOL> P_SSL_CTX <EOL> ] <EOL> libssl . SSL_CTX_free . restype = None <EOL> libssl . SSL_new . argtypes = [ <EOL> P_SSL_CTX <EOL> ] <EOL> libssl . SSL_new . restype = P_SSL <EOL> libssl . SSL_free . argtypes = [ <EOL> P_SSL <EOL> ] <EOL> libssl . SSL_free . restype = None <EOL> libssl . SSL_set_bio . argtypes = [ <EOL> P_SSL , <EOL> P_BIO , <EOL> P_BIO <EOL> ] <EOL> libssl . SSL_set_bio . restype = None <EOL> libssl . SSL_ctrl . arg_types = [ <EOL> P_SSL , <EOL> c_int , <EOL> c_long , <EOL> c_void_p <EOL> ] <EOL> libssl . SSL_ctrl . restype = c_long <EOL> libssl . SSL_get_peer_cert_chain . argtypes = [ <EOL> P_SSL <EOL> ] <EOL> libssl . SSL_get_peer_cert_chain . restype = P_STACK <EOL> libssl . SSL_get1_session . argtypes = [ <EOL> P_SSL <EOL> ] <EOL> libssl . SSL_get1_session . restype = P_SSL_SESSION <EOL> libssl . SSL_set_session . argtypes = [ <EOL> P_SSL , <EOL> P_SSL_SESSION <EOL> ] <EOL> libssl . SSL_set_session . restype = c_int <EOL> libssl . SSL_SESSION_free . argtypes = [ <EOL> P_SSL_SESSION <EOL> ] <EOL> libssl . SSL_SESSION_free . restype = None <EOL> libssl . SSL_set_connect_state . argtypes = [ <EOL> P_SSL <EOL> ] <EOL> libssl . SSL_set_connect_state . restype = None <EOL> libssl . SSL_do_handshake . argtypes = [ <EOL> P_SSL <EOL> ] <EOL> libssl . SSL_do_handshake . restype = c_int <EOL> libssl . SSL_state . argtypes = [ <EOL> P_SSL <EOL> ] <EOL> libssl . SSL_state . restype = c_int <EOL> libssl . SSL_get_error . argtypes = [ <EOL> P_SSL , <EOL> c_int <EOL> ] <EOL> libssl . SSL_get_error . restype = c_int <EOL> libssl . SSL_get_version . argtypes = [ <EOL> P_SSL <EOL> ] <EOL> libssl . SSL_get_version . restype = c_char_p <EOL> libssl . SSL_read . argtypes = [ <EOL> P_SSL , <EOL> c_char_p , <EOL> c_int <EOL> ] <EOL> libssl . SSL_read . restype = c_int <EOL> libssl . SSL_write . argtypes = [ <EOL> P_SSL , <EOL> c_char_p , <EOL> c_int <EOL> ] <EOL> libssl . SSL_write . restype = c_int <EOL> libssl . SSL_pending . argtypes = [ <EOL> P_SSL <EOL> ] <EOL> libssl . SSL_pending . restype = c_int <EOL> libssl . SSL_shutdown . argtypes = [ <EOL> P_SSL <EOL> ] <EOL> libssl . SSL_shutdown . restype = c_int <EOL> except ( AttributeError ) : <EOL> raise FFIEngineError ( '<STR_LIT>' ) <EOL> setattr ( libssl , '<STR_LIT>' , _STACK ) <EOL> setattr ( libssl , '<STR_LIT>' , X509 ) </s>
