<#e8 ddlZddlZddlmZddlmZmZddlmZm Z ddl m Z ddl m Z ddlmZmZmZmZmZmZmZmZddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%gd Z&ejNZ'ejPxZ(Z)ejTxZ*Z+ejXxZ,Z-ej\xZ.Z/ej`xZ0Z1ejdZ3ejhZ5d Z6d Z7d Z8d Z9dZ:dZ;dZdZ? ejZ@ejZAejZBejZCejZDejZGejZIejZKejZMejZO ejZQe&jdejZTejZVejZXejZZejZ\ejZ^ejZ`ejZbejZdejZfejZhejZjejZlejZnejZpejZrejZtejZvejZxejZzejZ|ejZ~ejZejZ ejZe&jd ej Ze&jdejZejZejZejZejZej"Zej&Zej*Zej.Zej2Zej6Zej:Zej>ZejBZejDZejFZejHZejJZejLZejNZejPZejRZejTZejVZejXZejZZej\Zej^Zej`ZGddZgdZdgZd Zd!ZGd"d#eZeeeZeeZGd$d%eZGd&d'eZGd(d)eZGd*d+eZGd,d-eZGd.d/ZGd0d1eZeZGd2d3eZGd4d5eZGd6d7eZGd8d9eZGd:d;eZd<Zd=ZeZd>Zeejd?Zeeed@ddAZGdBdCZGdDdEZGdFdGZy#eE$rdZ@dZAdZBdZCdZDYNwxYw#eE$rYwxYw#eE$rYwxYw#eE$rYwxYw)HN) errorcode)partialwraps)chaincount)platform)WeakValueDictionary) UNSPECIFIEDexception_from_error_queueffilib make_assertno_zero_allocator path_bytestext_to_bytes_and_warn) FILETYPE_PEMPKeyX509X509Name X509Store_PassphraseHelper)bOPENSSL_VERSION_NUMBERSSLEAY_VERSION SSLEAY_CFLAGSSSLEAY_PLATFORM SSLEAY_DIRSSLEAY_BUILT_ONOPENSSL_VERSIONOPENSSL_CFLAGSOPENSSL_PLATFORM OPENSSL_DIROPENSSL_BUILT_ON SENT_SHUTDOWNRECEIVED_SHUTDOWN SSLv23_METHOD TLSv1_METHODTLSv1_1_METHODTLSv1_2_METHOD TLS_METHODTLS_SERVER_METHODTLS_CLIENT_METHOD DTLS_METHODDTLS_SERVER_METHODDTLS_CLIENT_METHOD SSL3_VERSION TLS1_VERSIONTLS1_1_VERSIONTLS1_2_VERSIONTLS1_3_VERSION OP_NO_SSLv2 OP_NO_SSLv3 OP_NO_TLSv1 OP_NO_TLSv1_1 OP_NO_TLSv1_2MODE_RELEASE_BUFFERSOP_SINGLE_DH_USEOP_SINGLE_ECDH_USEOP_EPHEMERAL_RSAOP_MICROSOFT_SESS_ID_BUGOP_NETSCAPE_CHALLENGE_BUG#OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUGOP_SSLREF2_REUSE_CERT_TYPE_BUGOP_MICROSOFT_BIG_SSLV3_BUFFEROP_MSIE_SSLV2_RSA_PADDINGOP_SSLEAY_080_CLIENT_DH_BUG OP_TLS_D5_BUGOP_TLS_BLOCK_PADDING_BUGOP_DONT_INSERT_EMPTY_FRAGMENTSOP_CIPHER_SERVER_PREFERENCEOP_TLS_ROLLBACK_BUGOP_PKCS1_CHECK_1OP_PKCS1_CHECK_2OP_NETSCAPE_CA_DN_BUG"OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUGOP_NO_COMPRESSIONOP_NO_QUERY_MTUOP_COOKIE_EXCHANGE OP_NO_TICKETOP_ALL VERIFY_PEERVERIFY_FAIL_IF_NO_PEER_CERTVERIFY_CLIENT_ONCE VERIFY_NONESESS_CACHE_OFFSESS_CACHE_CLIENTSESS_CACHE_SERVERSESS_CACHE_BOTHSESS_CACHE_NO_AUTO_CLEARSESS_CACHE_NO_INTERNAL_LOOKUPSESS_CACHE_NO_INTERNAL_STORESESS_CACHE_NO_INTERNALSSL_ST_CONNECT SSL_ST_ACCEPT SSL_ST_MASK SSL_CB_LOOP SSL_CB_EXIT SSL_CB_READ SSL_CB_WRITE SSL_CB_ALERTSSL_CB_READ_ALERTSSL_CB_WRITE_ALERTSSL_CB_ACCEPT_LOOPSSL_CB_ACCEPT_EXITSSL_CB_CONNECT_LOOPSSL_CB_CONNECT_EXITSSL_CB_HANDSHAKE_STARTSSL_CB_HANDSHAKE_DONEError WantReadErrorWantWriteErrorWantX509LookupErrorZeroReturnError SysCallErrorNO_OVERLAPPING_PROTOCOLSSSLeay_versionSessionContext ConnectionX509VerificationCodes iiiii OP_NO_TLSv1_3OP_NO_RENEGOTIATIONOP_IGNORE_UNEXPECTED_EOFcheZdZdZej ZejZejZ ejZ ejZejZej"Zej&Zej*Zej.Zej2Zej6Zej:Zej>Z ejBZ"ejFZ$ejJZ&ejNZ(ejRZ*ejVZ,ejZZ.ej^Z0ejbZ2ejfZ4ejjZ6ejnZ8ejrZ:ejvZej~Z@ejZBejZDejZFejZHejZJejZLejZNejZPejZRejZTejZVejZXejZZejZ\ejZ^ejZ`ejZbejZdejZfejZhejZjejZlejZnejZpejZrejZtejZvy)rya\ Success and error codes for X509 verification, as returned by the underlying ``X509_STORE_CTX_get_error()`` function and passed by pyOpenSSL to verification callback functions. See `OpenSSL Verification Errors `_ for details. N)w__name__ __module__ __qualname____doc___lib X509_V_OKOK$X509_V_ERR_UNABLE_TO_GET_ISSUER_CERTERR_UNABLE_TO_GET_ISSUER_CERTX509_V_ERR_UNABLE_TO_GET_CRLERR_UNABLE_TO_GET_CRL+X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE$ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE*X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE#ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE-X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY&ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY!X509_V_ERR_CERT_SIGNATURE_FAILUREERR_CERT_SIGNATURE_FAILURE X509_V_ERR_CRL_SIGNATURE_FAILUREERR_CRL_SIGNATURE_FAILUREX509_V_ERR_CERT_NOT_YET_VALIDERR_CERT_NOT_YET_VALIDX509_V_ERR_CERT_HAS_EXPIREDERR_CERT_HAS_EXPIREDX509_V_ERR_CRL_NOT_YET_VALIDERR_CRL_NOT_YET_VALIDX509_V_ERR_CRL_HAS_EXPIREDERR_CRL_HAS_EXPIRED)X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD"ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD(X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD!ERR_ERROR_IN_CERT_NOT_AFTER_FIELD)X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD"ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD)X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD"ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELDX509_V_ERR_OUT_OF_MEMERR_OUT_OF_MEM&X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERTERR_DEPTH_ZERO_SELF_SIGNED_CERT$X509_V_ERR_SELF_SIGNED_CERT_IN_CHAINERR_SELF_SIGNED_CERT_IN_CHAIN,X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY%ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY*X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE#ERR_UNABLE_TO_VERIFY_LEAF_SIGNATUREX509_V_ERR_CERT_CHAIN_TOO_LONGERR_CERT_CHAIN_TOO_LONGX509_V_ERR_CERT_REVOKEDERR_CERT_REVOKEDX509_V_ERR_INVALID_CAERR_INVALID_CAX509_V_ERR_PATH_LENGTH_EXCEEDEDERR_PATH_LENGTH_EXCEEDEDX509_V_ERR_INVALID_PURPOSEERR_INVALID_PURPOSEX509_V_ERR_CERT_UNTRUSTEDERR_CERT_UNTRUSTEDX509_V_ERR_CERT_REJECTEDERR_CERT_REJECTED"X509_V_ERR_SUBJECT_ISSUER_MISMATCHERR_SUBJECT_ISSUER_MISMATCHX509_V_ERR_AKID_SKID_MISMATCHERR_AKID_SKID_MISMATCH&X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCHERR_AKID_ISSUER_SERIAL_MISMATCHX509_V_ERR_KEYUSAGE_NO_CERTSIGNERR_KEYUSAGE_NO_CERTSIGN#X509_V_ERR_UNABLE_TO_GET_CRL_ISSUERERR_UNABLE_TO_GET_CRL_ISSUER'X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION ERR_UNHANDLED_CRITICAL_EXTENSIONX509_V_ERR_KEYUSAGE_NO_CRL_SIGNERR_KEYUSAGE_NO_CRL_SIGN+X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION$ERR_UNHANDLED_CRITICAL_CRL_EXTENSIONX509_V_ERR_INVALID_NON_CAERR_INVALID_NON_CA%X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDEDERR_PROXY_PATH_LENGTH_EXCEEDED(X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE!ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE)X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED"ERR_PROXY_CERTIFICATES_NOT_ALLOWEDX509_V_ERR_INVALID_EXTENSIONERR_INVALID_EXTENSION#X509_V_ERR_INVALID_POLICY_EXTENSIONERR_INVALID_POLICY_EXTENSIONX509_V_ERR_NO_EXPLICIT_POLICYERR_NO_EXPLICIT_POLICYX509_V_ERR_DIFFERENT_CRL_SCOPEERR_DIFFERENT_CRL_SCOPE(X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE!ERR_UNSUPPORTED_EXTENSION_FEATUREX509_V_ERR_UNNESTED_RESOURCEERR_UNNESTED_RESOURCEX509_V_ERR_PERMITTED_VIOLATIONERR_PERMITTED_VIOLATIONX509_V_ERR_EXCLUDED_VIOLATIONERR_EXCLUDED_VIOLATIONX509_V_ERR_SUBTREE_MINMAXERR_SUBTREE_MINMAX&X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPEERR_UNSUPPORTED_CONSTRAINT_TYPE(X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX!ERR_UNSUPPORTED_CONSTRAINT_SYNTAX"X509_V_ERR_UNSUPPORTED_NAME_SYNTAXERR_UNSUPPORTED_NAME_SYNTAX$X509_V_ERR_CRL_PATH_VALIDATION_ERRORERR_CRL_PATH_VALIDATION_ERRORX509_V_ERR_HOSTNAME_MISMATCHERR_HOSTNAME_MISMATCHX509_V_ERR_EMAIL_MISMATCHERR_EMAIL_MISMATCHX509_V_ERR_IP_ADDRESS_MISMATCHERR_IP_ADDRESS_MISMATCH#X509_V_ERR_APPLICATION_VERIFICATIONERR_APPLICATION_VERIFICATION-/usr/lib/python3/dist-packages/OpenSSL/SSL.pyryrys B$($M$M! == 88) 77( ::+"&!G!G $ E E!??;; ==99 66' 55& 66' 66'//N 33$%)$M$M! 99* 77(#AA33//N#CC997755"&"I"I!?? 33$ $CC#'#K#K  44% $CC 88)77%)%O%O" 55& 66'!==#'#K#K !??"AA 55&!=="AA!??77 33$ 55&#'"I"I$($M$M! ==77"AA#'#K#K rry)z"/etc/ssl/certs/ca-certificates.crtz /etc/pki/tls/certs/ca-bundle.crtz/etc/ssl/ca-bundle.pemz/etc/pki/tls/cacert.pemz1/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pemz/etc/ssl/certss$/opt/pyca/cryptography/openssl/certss'/opt/pyca/cryptography/openssl/cert.pemceZdZdZy)rnz4 An error occurred in an `OpenSSL.SSL` API. Nrrrrrrrrnrn|srrnc eZdZy)roNrrrrrrrororroc eZdZy)rpNrrrrrprprrrpc eZdZy)rqNrrrrrqrqrrrqc eZdZy)rrNrrrrrrrrrrrrc eZdZy)rsNrrrrrsrsrrrsceZdZdZdZdZy)_CallbackExceptionHelpera A base class for wrapper classes that allow for intelligent exception handling in OpenSSL callbacks. :ivar list _problems: Any exceptions that occurred while executing in a context where they could not be raised in the normal way. Typically this is because OpenSSL has called into some Python code and requires a return value. The exceptions are saved to be raised later when it is possible to do so. cg|_yN) _problemsselfs r__init__z!_CallbackExceptionHelper.__init__s rc|jr& t|jjdy#t$rY'wxYw)z Raise an exception from the OpenSSL error queue or that was previously captured whe running a callback. rN)r_raise_current_errorrnpoprs rraise_if_problemz)_CallbackExceptionHelper.raise_if_problemsF >> $&..$$Q' '   s 4 AAN)rrrrrrrrrr r s  (rr ceZdZdZdZy) _VerifyHelperz^ Wrap a callback such that it can be used as a certificate verification callback. ctjtfd}tjd|_y)Nctj|}tj|tj|}tj |}tj |}tj}tj||}tj|}  |||||} | r%tj|tjyy#t$r%} jj| Yd} ~ yd} ~ wwxYw)Nr)rX509_STORE_CTX_get_current_cert X509_up_refr_from_raw_x509_ptrX509_STORE_CTX_get_errorX509_STORE_CTX_get_error_depth"SSL_get_ex_data_X509_STORE_CTX_idxX509_STORE_CTX_get_ex_datarx_reverse_mappingX509_STORE_CTX_set_errorr Exceptionrappend) ok store_ctxx509cert error_number error_depthindexssl connectionresultecallbackrs rwrapperz'_VerifyHelper.__init__..wrappers77 BD   T "**40D88CL==iHK;;=E11)UCC#44S9J !lK11)T^^L %%a( s) C D &DD zint (*)(int, X509_STORE_CTX *)r rr_ffir2rr2r3s`` rrz_VerifyHelper.__init__s> ))$/ x   2 ,g  rNrrrrrrrrrrs   rrceZdZdZdZy)_ALPNSelectHelperzQ Wrap a callback such that it can be used as an ALPN selection callback. ctjtfd}tjd|_y)Nc tj|}tj||dd}g}|r)|d} |d| dz} |j | || dzd}|r)||} d} | t urd} d} nt | ts tdtjdt| tjd| g|_ |jdd|d<|jd|d<| stjStjS#t$r5} j j | tj"cYd} ~ Sd} ~ wwxYw) NrrTrFz^ALPN callback must return a bytestring or the special NO_OVERLAPPING_PROTOCOLS sentinel value.zunsigned char *unsigned char[])rxr#r5bufferr&rt isinstancebytes TypeErrornewlen_alpn_select_callback_argsrSSL_TLSEXT_ERR_NOACKSSL_TLSEXT_ERR_OKr%rSSL_TLSEXT_ERR_ALERT_FATAL)r.outoutlenin_inlenargconninstr protolist encoded_lenprotooutbytes any_acceptedr1r2rs rr3z+_ALPNSelectHelper.__init__..wrappers]( 7!2237  C/2 "'(K!!kAo6E$$U+!+/"34E $D)4# 77"H#(L#He4#KHH.H >HH.93/!;;A>qAq 88;A#444--- 7%%a(666 7s+ADB%DD E*E E Ez^int (*)(SSL *, unsigned char **, unsigned char *, const unsigned char *, unsigned int, void *)r4r6s`` rrz_ALPNSelectHelper.__init__sD ))$/ x) 7 ) 7V ?    rNr7rrrr9r9s 5 rr9ceZdZdZdZy)_OCSPServerCallbackHelpera Wrap a callback such that it can be used as an OCSP callback for the server side. Annoyingly, OpenSSL defines one OCSP callback but uses it in two different ways. For servers, that callback is expected to retrieve some OCSP data and hand it to OpenSSL, and may return only SSL_TLSEXT_ERR_OK, SSL_TLSEXT_ERR_FATAL, and SSL_TLSEXT_ERR_NOACK. For clients, that callback is expected to check the OCSP data, and returns a negative value on error, 0 if the response is not acceptable, or positive if it is. These are mutually exclusive return code behaviours, and they mean that we need two helpers so that we always return an appropriate error code if the user's code throws an exception. Given that we have to have two helpers anyway, these helpers are a bit more helpery than most: specifically, they hide a few more of the OpenSSL functions so that the user has an easier time writing these callbacks. This helper implements the server side. ctjtfd}tjd|_y)Nc tj|}|tjk7rtj|}nd}||}t |t s td|syt|}tj|}|tj||ddtj|||y#t$r%} jj|Yd}~yd}~wwxYw)Nz'OCSP callback must return a bytestring.rzr)rxr#r5NULL from_handler>r?r@rBrOPENSSL_mallocr=SSL_set_tlsext_status_ocsp_respr%rr&) r.cdatarLdata ocsp_dataocsp_data_lengthdata_ptrr1r2rs rr3z3_OCSPServerCallbackHelper.__init__..wrapper7s# !2237DII%++E2DD%T40 !)U3#$MNN !$'y> ../?@=F H&67:44#3 %%a( sA$B9(AB99 C'C""C'int (*)(SSL *, void *)r4r6s`` rrz"_OCSPServerCallbackHelper.__init__4s= ))$/ x$  $ L &>H rNr7rrrrTrTs **IrrTceZdZdZdZy)_OCSPClientCallbackHelpera Wrap a callback such that it can be used as an OCSP callback for the client side. Annoyingly, OpenSSL defines one OCSP callback but uses it in two different ways. For servers, that callback is expected to retrieve some OCSP data and hand it to OpenSSL, and may return only SSL_TLSEXT_ERR_OK, SSL_TLSEXT_ERR_FATAL, and SSL_TLSEXT_ERR_NOACK. For clients, that callback is expected to check the OCSP data, and returns a negative value on error, 0 if the response is not acceptable, or positive if it is. These are mutually exclusive return code behaviours, and they mean that we need two helpers so that we always return an appropriate error code if the user's code throws an exception. Given that we have to have two helpers anyway, these helpers are a bit more helpery than most: specifically, they hide a few more of the OpenSSL functions so that the user has an easier time writing these callbacks. This helper implements the client side. ctjtfd}tjd|_y)Nc tj|}|tjk7rtj|}nd}tj d}t j||}|dkrd}ntj|d|dd} |||}tt|S#t$r%} jj|Yd}~yd}~wwxYw)Nunsigned char **rr)rxr#r5rXrYrArSSL_get_tlsext_status_ocsp_respr=intboolr%rr&) r.r\rLr]ocsp_ptrocsp_lenr^validr1r2rs rr3z3_OCSPClientCallbackHelper.__init__..wrapperzs !2237DII%++E2DD 88$67??XNa< #I!% HQK B1 EI y$74;'' %%a( sB*B.. C7CCrar4r6s`` rrz"_OCSPClientCallbackHelper.__init__ws< ))$/ x   < &>H rNr7rrrrcrcas *"IrrcceZdZdZy)_CookieGenerateCallbackHelperctjtfd}tjd|_y)Nc tj|}|}||dt|t||d<y#t$r%}jj |Yd}~yd}~wwxYw)Nrr)rxr#rBr%rr&)r.rGrHrLcookier1r2rs rr3z7_CookieGenerateCallbackHelper.__init__..wrappersf !2237!$'-AF $Kq  %%a( s7; A)A$$A)z/int (*)(SSL *, unsigned char *, unsigned int *)r4r6s`` rrz&_CookieGenerateCallbackHelper.__init__s? ))$/ x    =   rNrrrrrrrroros rroceZdZdZy)_CookieVerifyCallbackHelperctjtfd}tjd|_y)Nc tj|}|t|d|S#t$r%}jj |Yd}~yd}~wwxYwNr)rxr#r?r%rr&)r.c_cookie cookie_lenrLr1r2rs rr3z5_CookieVerifyCallbackHelper.__init__..wrappersV !2237eHQz,B&CDD %%a( s'+ AAAz-int (*)(SSL *, unsigned char *, unsigned int)r4r6s`` rrz$_CookieVerifyCallbackHelper.__init__s? ))$/ x    ;   rNrsrrrrurus rrucd}t|tst|dd}||}t|tr|}t|ts td|dkrt d|fz|S)Nfilenoz3argument must be an int, or have a fileno() method.rz1file descriptor cannot be a negative integer (%i))r>rigetattrr@ ValueError)objfdmeths r_asFileDescriptorrsv B c3 sHd+  &C#s  b# MNN a ?2% G   IrcRtjtj|S)z Return a string describing the version of OpenSSL in use. :param type: One of the :const:`OPENSSL_` constants defined in this module. )r5stringrOpenSSL_version)types rrrs ;;t++D1 22rcfd}|S)a Builds a decorator that ensures that functions that rely on OpenSSL functions that are not present in this build raise NotImplementedError, rather than AttributeError coming out of cryptography. :param flag: A cryptography flag that guards the functions, e.g. ``Cryptography_HAS_NEXTPROTONEG``. :param error: The string to be used in the exception if the flag is false. c6st|fd}|S|S)NctrNotImplementedError)argskwargserrors rexplodez<_make_requires.._requires_decorator..explodes)%00r)r)funcrrflags r_requires_decoratorz+_make_requires.._requires_decorators( 4[ 1 1NKrr)rrrs`` r_make_requiresrs  rzALPN not availableCryptography_HAS_KEYLOGzKey logging not availableceZdZdZy)rvz A class representing an SSL session. A session defines certain connection parameters which may be re-used to speed up the setup of subsequent connections. .. versionadded:: 0.14 Nrrrrrvrv s  rrvc|eZdZdZeej dfeej efe ej e fe ej e fe ej dfeejdfeej"dfeej&dfeej*dfeej.dfi ZdZdZdZd3dZdZd3dZd Zd Z d Z!d Z"e#fd Z$dZ%dZ&dZ'e(fdZ)dZ*dZ+dZ,dZ-dZ.dZ/d3dZ0dZ1dZ2dZ3dZ4dZ5dZ6dZ7d Z8d!Z9d"Z:d#Z;ed&Z?d'Z@d(ZAd)ZBd*ZCd+ZDeEd,ZFeEd-ZGd.ZHd3d/ZId3d0ZJd1ZKd2ZLy)4rwau :class:`OpenSSL.SSL.Context` instances define the parameters for setting up new SSL connections. :param method: One of TLS_METHOD, TLS_CLIENT_METHOD, TLS_SERVER_METHOD, DTLS_METHOD, DTLS_CLIENT_METHOD, or DTLS_SERVER_METHOD. SSLv23_METHOD, TLSv1_METHOD, etc. are deprecated and should not be used. Nct|ts td |j|\}}|}t |tjk7tj|}t |tjk7tj|tj}||_ d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_|j=tj>|#|jA||jC|yy#t$r t dwxYw)Nzmethod must be an integerzNo such protocol)"r>rir@_methodsKeyErrorr~_openssl_assertr5rXr SSL_CTX_newgc SSL_CTX_free_context_passphrase_helper_passphrase_callback_passphrase_userdata_verify_helper_verify_callback_info_callback_keylog_callback_tlsext_servername_callback _app_data_alpn_select_helper_alpn_select_callback _ocsp_helper_ocsp_callback _ocsp_data_cookie_generate_helper_cookie_verify_helperset_modeSSL_MODE_ENABLE_PARTIAL_WRITEset_min_proto_versionset_max_proto_version)rmethod method_funcversion method_objcontexts rrzContext.__init__-s\&#&78 8 1#'==#8 K!]  dii/0"":.499,-'''4#4#45 "&$(!$(!" $" $+/(#' %)" "'+$%)" d889    & &w /  & &w / ; 1/0 0 1s E##E8c\ttj|j|dk(y)aD Set the minimum supported protocol version. Setting the minimum version to 0 will enable protocol versions down to the lowest version supported by the library. If the underlying OpenSSL build is missing support for the selected version, this method will raise an exception. rN)rrSSL_CTX_set_min_proto_versionrrrs rrzContext.set_min_proto_versionT%   . .t}}g F! K rc\ttj|j|dk(y)aC Set the maximum supported protocol version. Setting the maximum version to 0 will enable protocol versions up to the highest version supported by the library. If the underlying OpenSSL build is missing support for the selected version, this method will raise an exception. rN)rrSSL_CTX_set_max_proto_versionrrs rrzContext.set_max_proto_versionarrc|tj}n t|}|tj}n t|}tj|j ||}|s t yy)aU Let SSL know where we can find trusted certificates for the certificate chain. Note that the certificates have to be in PEM format. If capath is passed, it must be a directory prepared using the ``c_rehash`` tool included with OpenSSL. Either, but not both, of *pemfile* or *capath* may be :data:`None`. :param cafile: In which file we can find the certificates (``bytes`` or ``unicode``). :param capath: In which directory we can find the certificates (``bytes`` or ``unicode``). :return: None N)r5rX _path_bytesrSSL_CTX_load_verify_locationsrr)rcafilecapath load_results rload_verify_locationszContext.load_verify_locationsns_ >YYF (F >YYF (F88 MM66  "rcTtfd}tt|ddS)Nc,||jSr)r)sizeverifyuserdatar2rs rr3z'Context._wrap_callback..wrappersD&$*C*CD DrT) more_argstruncate)rrrr6s`` r_wrap_callbackzContext._wrap_callbacks3 x E  E! 'TD  rct|s td|j||_|jj|_t j|j|j ||_ y)a Set the passphrase callback. This function will be called when a private key with a passphrase is loaded. :param callback: The Python callback to use. This must accept three positional arguments. First, an integer giving the maximum length of the passphrase it may return. If the returned passphrase is longer than this, it will be truncated. Second, a boolean value which will be true if the user should be prompted for the passphrase twice and the callback should verify that the two values supplied are equal. Third, the value given as the *userdata* parameter to :meth:`set_passwd_cb`. The *callback* must return a byte string. If an error occurs, *callback* should return a false value (e.g. an empty string). :param userdata: (optional) A Python object which will be given as argument to the callback :return: None callback must be callableN) callabler@rrr2rrSSL_CTX_set_default_passwd_cbrr)rr2rs r set_passwd_cbzContext.set_passwd_cbsf&!78 8"&"5"5h"?$($;$;$D$D! ** MM444 %-!rcTtj|j}t|dk(t j tj jd}t j tjjd}|j||s}t j tj}t j tj}|tk(r%|tk(r|jtt yyyy)a Specify that the platform provided CA certificates are to be used for verification purposes. This method has some caveats related to the binary wheels that cryptography (pyOpenSSL's primary dependency) ships: * macOS will only load certificates using this method if the user has the ``openssl@1.1`` `Homebrew `_ formula installed in the default location. * Windows will not work. * manylinux1 cryptography wheels will work on most common Linux distributions in pyOpenSSL 17.1.0 and above. pyOpenSSL detects the manylinux1 wheel and attempts to load roots via a fallback path. :return: None rasciiN)r SSL_CTX_set_default_verify_pathsrrr5rX509_get_default_cert_dir_envdecodeX509_get_default_cert_file_env_check_env_vars_setX509_get_default_cert_dirX509_get_default_cert_file_CRYPTOGRAPHY_MANYLINUX_CA_DIR_CRYPTOGRAPHY_MANYLINUX_CA_FILE_fallback_default_verify_paths_CERTIFICATE_FILE_LOCATIONS_CERTIFICATE_PATH_LOCATIONS)r set_result dir_env_var file_env_var default_dir default_files rset_default_verify_pathsz Context.set_default_verify_pathss(::4==I  a( kk$"D"D"FGNN  {{  / / 1 &/ '' \B++d&D&D&FGK;;t'F'F'HIL == $CC33/1LD>Crctjj|duxs!tjj|duS)zp Check to see if the default cert dir/file environment vars are present. :return: bool N)osenvironget)rrrs rrzContext._check_env_vars_sets8 JJNN< ( 4 7zz~~k*$6 rc|D]4}tjj|s#|j|n|D]5}tjj |s#|jd|yy)aW Default verify paths are based on the compiled version of OpenSSL. However, when pyca/cryptography is compiled as a manylinux1 wheel that compiled location can potentially be wrong. So, like Go, we will try a predefined set of paths and attempt to load roots from there. :return: None N)rpathisfilerisdir)r file_pathdir_pathrrs rrz&Context._fallback_default_verify_pathssh  Fww~~f%**62   Fww}}V$**48 rctt|}tj|j|}|s t yy)z Load a certificate chain from a file. :param certfile: The name of the certificate chain file (``bytes`` or ``unicode``). Must be PEM encoded. :return: None N)rr"SSL_CTX_use_certificate_chain_filerr)rcertfiler0s ruse_certificate_chain_filez"Context.use_certificate_chain_files7x(88 MM8  "rct|}t|ts tdt j |j ||}|s tyy)ah Load a certificate from a file :param certfile: The name of the certificate file (``bytes`` or ``unicode``). :param filetype: (optional) The encoding of the file, which is either :const:`FILETYPE_PEM` or :const:`FILETYPE_ASN1`. The default is :const:`FILETYPE_PEM`. :return: None filetype must be an integerN)rr>rir@rSSL_CTX_use_certificate_filerr)rrfiletype use_results ruse_certificate_filezContext.use_certificate_filesOx((C(9: :66 MM8X  "rct|ts tdtj|j |j }|s tyyzs Load a certificate from a X509 object :param cert: The X509 object :return: None zcert must be an X509 instanceN)r>rr@rSSL_CTX_use_certificater_x509rrr*rs ruse_certificatezContext.use_certificate*sB$%;< <11$--L  "rct|ts tdtj|j }tj |j|}|s tj|tyy)z Add certificate to chain :param certobj: The X509 certificate object to add to the chain :return: None z certobj must be an X509 instanceN) r>rr@rX509_duprSSL_CTX_add_extra_chain_certr X509_freer)rcertobjcopy add_results radd_extra_chain_certzContext.add_extra_chain_cert9s\'4(>? ?}}W]]+66t}}dK  NN4 "rcn|j|jjttyr)rrrnrrs r_raise_passphrase_exceptionz#Context._raise_passphrase_exceptionJs(  " " .  # # 4 4U ;rct|}|turt}nt|ts t dt j|j||}|s|jyy)aR Load a private key from a file :param keyfile: The name of the key file (``bytes`` or ``unicode``) :param filetype: (optional) The encoding of the file, which is either :const:`FILETYPE_PEM` or :const:`FILETYPE_ASN1`. The default is :const:`FILETYPE_PEM`. :return: None rN) r _UNSPECIFIEDrr>rir@rSSL_CTX_use_PrivateKey_filerr )rkeyfilerrs ruse_privatekey_filezContext.use_privatekey_filePsbg& | ##HHc*9: :55 MM7H   , , .rct|ts tdtj|j |j }|s|jyyzs Load a private key from a PKey object :param pkey: The PKey object :return: None zpkey must be a PKey instanceN)r>rr@rSSL_CTX_use_PrivateKeyr_pkeyr rpkeyrs ruse_privatekeyzContext.use_privatekeyhsH$%:; ;00 K   , , .rcXtj|js tyy)z Check if the private key (loaded with :meth:`use_privatekey`) matches the certificate (loaded with :meth:`use_certificate`) :return: :data:`None` (raises :exc:`Error` if something's wrong) N)rSSL_CTX_check_private_keyrrrs rcheck_privatekeyzContext.check_privatekeyws!--dmm< "=rctjtd|}t|tj k7tj |j|y)a% Load the trusted certificates that will be sent to the client. Does not actually imply any of the certificates are trusted; that must be configured separately. :param bytes cafile: The path to a certificates file in PEM format. :return: None rN)rSSL_load_client_CA_file_text_to_bytes_and_warnrr5rXSSL_CTX_set_client_CA_listr)rrca_lists rload_client_cazContext.load_client_casE.. #Hf 5  499,- '' w?rc td|}ttj|j|t |dk(y)aV Set the session id to *buf* within which a session can be reused for this Context object. This is needed when doing session resumption, because there is no way for a stored session to know which Context object it is associated with. :param bytes buf: The session id. :returns: None bufrN)rrrSSL_CTX_set_session_id_contextrrB)rr s rset_session_idzContext.set_session_ids:&eS1  / / sCH M  rcxt|ts tdtj|j |S)a Set the behavior of the session cache used by all connections using this Context. The previously set mode is returned. See :const:`SESS_CACHE_*` for details about particular modes. :param mode: One or more of the SESS_CACHE_* flags (combine using bitwise or) :returns: The previously set caching mode. .. versionadded:: 0.14 mode must be an integer)r>rir@rSSL_CTX_set_session_cache_moderrmodes rset_session_cache_modezContext.set_session_cache_modes1$$56 6224==$GGrc@tj|jS)z Get the current session cache mode. :returns: The currently used cache mode. .. versionadded:: 0.14 )rSSL_CTX_get_session_cache_moderrs rget_session_cache_modezContext.get_session_cache_modes224==AArct|ts td|>d|_d|_t j |j|tjyt|s tdt||_|jj|_t j |j||jy)a Set the verification flags for this Context object to *mode* and specify that *callback* should be used for verification callbacks. :param mode: The verify mode, this should be one of :const:`VERIFY_NONE` and :const:`VERIFY_PEER`. If :const:`VERIFY_PEER` is used, *mode* can be OR:ed with :const:`VERIFY_FAIL_IF_NO_PEER_CERT` and :const:`VERIFY_CLIENT_ONCE` to further control the behaviour. :param callback: The optional Python verification callback to use. This should take five arguments: A Connection object, an X509 object, and three integer variables, which are in turn potential error number, error depth and return code. *callback* should return True if verification passes and False otherwise. If omitted, OpenSSL's default verification is used. :return: None See SSL_CTX_set_verify(3SSL) for further details. r$Nr) r>rir@rrrSSL_CTX_set_verifyrr5rXrrr2rr'r2s r set_verifyzContext.set_verifys($$56 6  "&D $(D !  # #DMM4 CH% ;<<"/"9D $($7$7$@$@D !  # #DMM49N9N Orczt|ts tdtj|j |y)z Set the maximum depth for the certificate chain verification that shall be allowed for this Context object. :param depth: An integer specifying the verify depth :return: None zdepth must be an integerN)r>rir@rSSL_CTX_set_verify_depthr)rdepths rset_verify_depthzContext.set_verify_depths.%%67 7 %%dmmU;rc@tj|jS)z Retrieve the Context object's verify mode, as set by :meth:`set_verify`. :return: The verify mode )rSSL_CTX_get_verify_moderrs rget_verify_modezContext.get_verify_modes++DMM::rc@tj|jS)z Retrieve the Context object's verify depth, as set by :meth:`set_verify_depth`. :return: The verify depth )rSSL_CTX_get_verify_depthrrs rget_verify_depthzContext.get_verify_depths,,T]];;rct|}tj|d}|tjk(r t tj |tj}tj|tjtjtj}tj |tj}tj|j|}t|dk(y)z Load parameters for Ephemeral Diffie-Hellman :param dhfile: The file to load EDH parameters from (``bytes`` or ``unicode``). :return: None rrN) rr BIO_new_filer5rXrrBIO_freePEM_read_bio_DHparamsDH_freeSSL_CTX_set_tmp_dhrr)rdhfilebiodhress r load_tmp_dhzContext.load_tmp_dhsV$- $))  "ggc4==)  ' 'TYY 499 M WWR &%%dmmR8q!rc`tj|j|jy)a  Select a curve to use for ECDHE key exchange. :param curve: A curve object to use as returned by either :meth:`OpenSSL.crypto.get_elliptic_curve` or :meth:`OpenSSL.crypto.get_elliptic_curves`. :return: None N)rSSL_CTX_set_tmp_ecdhr _to_EC_KEY)rcurves r set_tmp_ecdhzContext.set_tmp_ecdhs! !!$--1A1A1CDrctd|}t|ts tdt t j |j|dk(t|d}|jgdk(r tdgy)z Set the list of ciphers to be used in this context. See the OpenSSL manual for more information (e.g. :manpage:`ciphers(1)`). :param bytes cipher_list: An OpenSSL cipher string. :return: None cipher_listz"cipher_list must be a byte string.rN)TLS_AES_256_GCM_SHA384TLS_CHACHA20_POLY1305_SHA256TLS_AES_128_GCM_SHA256)z SSL routinesSSL_CTX_set_cipher_listzno cipher match) rr>r?r@rrrPrrxget_cipher_listrn)rrLtmpconns rset_cipher_listzContext.set_cipher_lists.m[I +u-@A A  ( ( D I T4(  " " $)     rcFtj}t|tjk7 |D]}t |t s"tdt|jdtj|j}t|tjk7tj||}|rtj|t tj"|j$|y#t$rtj |wxYw)a_ Set the list of preferred client certificate signers for this server context. This list of certificate authorities will be sent to the client when the server requests a client certificate. :param certificate_authorities: a sequence of X509Names. :return: None .. versionadded:: 0.10 z)client CAs must be X509Name objects, not z objectsN)rsk_X509_NAME_new_nullrr5rXr>rr@rr X509_NAME_dup_namesk_X509_NAME_pushX509_NAME_freerr%sk_X509_NAME_freerr)rcertificate_authorities name_stackca_namer push_results rset_client_ca_listzContext.set_client_ca_listFs//1  dii/0 2 +!'84#%)']%;%;>))'--8 12"44ZF "''-(* + '' zB    " ": .  sB D=!D D ct|ts tdtj|j |j }t|dk(y)ai Add the CA certificate to the list of preferred signers for this context. The list of certificate authorities will be sent to the client when the server requests a client certificate. :param certificate_authority: certificate authority's X509 certificate. :return: None .. versionadded:: 0.10 z.certificate_authority must be an X509 instancerN)r>rr@rSSL_CTX_add_client_CArrr)rcertificate_authorityrs r add_client_cazContext.add_client_caisI/6LM M// MM066   a(rcxt|ts tdtj|j |S)aQ Set the timeout for newly created sessions for this Context object to *timeout*. The default value is 300 seconds. See the OpenSSL manual for more information (e.g. :manpage:`SSL_CTX_set_timeout(3)`). :param timeout: The timeout in (whole) seconds :return: The previous session timeout ztimeout must be an integer)r>rir@rSSL_CTX_set_timeoutr)rtimeouts r set_timeoutzContext.set_timeout~s1'3'89 9'' w??rc@tj|jS)z Retrieve session timeout, as set by :meth:`set_timeout`. The default is 300 seconds. :return: The session timeout )rSSL_CTX_get_timeoutrrs r get_timeoutzContext.get_timeouts'' 66rctfd}tjd||_t j |j |jy)a Set the information callback to *callback*. This function will be called from time to time during SSL handshakes. :param callback: The Python callback to use. This should take three arguments: a Connection object and two integers. The first integer specifies where in the SSL handshake the function was called, and the other the return code from a (possibly failed) internal function call. :return: None c<tj|||yrrxr#)r.where return_coder2s rr3z*Context.set_info_callback..wrappers Z005uk Jrzvoid (*)(const SSL *, int, int)N)rr5r2rrSSL_CTX_set_info_callbackrr6s ` rset_info_callbackzContext.set_info_callbacksQ x K  K#mm -w  &&t}}d6I6IJrctfd}tjd||_t j |j |jy)a Set the TLS key logging callback to *callback*. This function will be called whenever TLS key material is generated or received, in order to allow applications to store this keying material for debugging purposes. :param callback: The Python callback to use. This should take two arguments: a Connection object and a bytestring that contains the key material in the format used by NSS for its SSLKEYLOGFILE debugging output. :return: None cdtj|}tj||yr)r5rrxr#)r.liner2s rr3z,Context.set_keylog_callback..wrappers&;;t$D Z005t rir@rSSL_CTX_set_optionsr)roptionss r set_optionszContext.set_optionss1'3'89 9'' w??rcxt|ts tdtj|j |S)z Add modes via bitmask. Modes set before are not cleared! This method should be used with the :const:`MODE_*` constants. :param mode: The mode to add. :return: The new mode bitmask. r$)r>rir@rSSL_CTX_set_moderr&s rrzContext.set_modes1$$56 6$$T]]D99rctfd}tjd||_t j |j |jy)a Specify a callback function to be called when clients specify a server name. :param callback: The callback function. It will be invoked with one argument, the Connection instance. .. versionadded:: 0.13 c8tj|yrxrm)r.alertrKr2s rr3z7Context.set_tlsext_servername_callback..wrapper s Z005 6rzint (*)(SSL *, int *, void *)N)rr5r2rr&SSL_CTX_set_tlsext_servername_callbackrr6s ` rset_tlsext_servername_callbackz&Context.set_tlsext_servername_callbacksR x   ,0== +W, ( 33 MM4;; rct|ts tdtt j |j |dk(y)z Enable support for negotiating SRTP keying material. :param bytes profiles: A colon delimited list of protection profile names, like ``b'SRTP_AES128_CM_SHA1_80:SRTP_AES128_CM_SHA1_32'``. :return: None zprofiles must be a byte string.rN)r>r?r@rrSSL_CTX_set_tlsext_use_srtpr)rprofiless rset_tlsext_use_srtpzContext.set_tlsext_use_srtps;(E*=> >  , ,T]]H E J rc  |s tddjtjd|D}t j d|}t tj|j|t|dk(y)a Specify the protocols that the client is prepared to speak after the TLS connection has been negotiated using Application Layer Protocol Negotiation. :param protos: A list of the protocols to be offered to the server. This list should be a Python list of bytestrings representing the protocols to offer, e.g. ``[b'http/1.1', b'spdy/2']``. 'at least one protocol must be specifiedrc3JK|]}tt|f|fywrr?rB.0ps r z*Context.set_alpn_protos..: F!Ay!11 5F!#r<rN) r~joinr from_iterabler5rArrSSL_CTX_set_alpn_protosrrBrprotosprotostr input_strs rset_alpn_protoszContext.set_alpn_protos&s{FG G88   FvF F  HH.9   ( ( y#h-   rct||_|jj|_t j |j |jtjy)a Specify a callback function that will be called on the server when a client offers protocols using ALPN. :param callback: The callback function. It will be invoked with two arguments: the Connection, and a list of offered protocols as bytestrings, e.g ``[b'http/1.1', b'spdy/2']``. It can return one of those bytestrings to indicate the chosen protocol, the empty bytestring to terminate the TLS connection, or the :py:obj:`NO_OVERLAPPING_PROTOCOLS` to indicate that no offered protocol was selected, but that the connection should not be aborted. N) r9rr2rrSSL_CTX_set_alpn_select_cbrr5rXrr2s rset_alpn_select_callbackz Context.set_alpn_select_callbackLsH$5X#> %)%=%=%F%F" '' MM455tyy rcx||_|j|_|tj|_ntj ||_tj|j|j}t|dk(tj|j|j }t|dk(y)z This internal helper does the common work for ``set_ocsp_server_callback`` and ``set_ocsp_client_callback``, which is almost all of it. Nr) rr2rr5rXr new_handlerSSL_CTX_set_tlsext_status_cbrrSSL_CTX_set_tlsext_status_arg)rhelperr]rcs r_set_ocsp_callbackzContext._set_ocsp_callbackas #$oo <"iiDO"ood3DO  . . MM4..  a  / / t Oa rc>t|}|j||y)a Set a callback to provide OCSP data to be stapled to the TLS handshake on the server side. :param callback: The callback function. It will be invoked with two arguments: the Connection, and the optional arbitrary data you have provided. The callback must return a bytestring that contains the OCSP data to staple to the handshake. If no OCSP data is available for this connection, return the empty bytestring. :param data: Some opaque data that will be passed into the callback function when called. This can be used to avoid needing to do complex data lookups or to keep track of what context is being used. This parameter is optional. N)rTrrr2r]rs rset_ocsp_server_callbackz Context.set_ocsp_server_callbackus+84 -rc>t|}|j||y)a Set a callback to validate OCSP data stapled to the TLS handshake on the client side. :param callback: The callback function. It will be invoked with three arguments: the Connection, a bytestring containing the stapled OCSP assertion, and the optional arbitrary data you have provided. The callback must return a boolean that indicates the result of validating the OCSP data: ``True`` if the OCSP data is valid and the certificate can be trusted, or ``False`` if either the OCSP data is invalid or the certificate has been revoked. :param data: Some opaque data that will be passed into the callback function when called. This can be used to avoid needing to do complex data lookups or to keep track of what context is being used. This parameter is optional. N)rcrrs rset_ocsp_client_callbackz Context.set_ocsp_client_callbacks"+84 -rct||_tj|j|jj yr)rorrSSL_CTX_set_cookie_generate_cbrr2rs rset_cookie_generate_callbackz$Context.set_cookie_generate_callbacks3'DX'N$ ++ MM  ( ( 1 1 rct||_tj|j|jj yr)rurrSSL_CTX_set_cookie_verify_cbrr2rs rset_cookie_verify_callbackz"Context.set_cookie_verify_callbacks3%@%J" )) MM  & & / / rr)Mrrrrr%r TLS_methodr&r0r'r1r(r2r)r*TLS_server_methodr+TLS_client_methodr, DTLS_methodr-DTLS_server_methodr.DTLS_client_methodrrrrrrrrrrrrrrrr r rrrrr"r(r+r/r3r6r9rErJrSr_rcrgrjrq_requires_keylogrvryr}rrrrr_requires_alpnrrrrrrrrrrrwrws .t 5.9.9T__d+D22D9D22D9d&&-T44d;T44d; H%0N    #@ -:.`  (#"7C#, ##" 5A/0 /# @ "H"B!PF <;<"* E%N!CF)* @7K,OO0" @ : .  # # J  (!(.$.(  rrwceZdZeZdFdZdZdZdZdZ dZ dFdZ d Z d Z d Zd Zd ZdZdZdGdZeZdGdZdFdZeZdHdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$d Z%d!Z&d"Z'd#Z(d$Z)d%Z*d&Z+d'Z,d(Z-d)Z.d*Z/d+Z0d,Z1d-Z2dFd.Z3d/Z4d0Z5d1Z6e7d2Z8d3Z9d4Z:d5Z;d6Zd9Z?d:Z@d;ZAd<ZBd=ZCd>ZDd?ZEd@ZFdAZGdBZHeIdCZJeIdDZKdEZLy)IrxNc|t|ts tdtj|j }t j|tj|_ tj|jtj||_d|_ d|_ |j|_|j|_|j |_|j"|_||j$|j<|d|_tj(tj*|_t/|j,t j0k7tj(tj*|_t/|j2t j0k7tj4|j|j,|j2yd|_d|_||_tj6|jt9|j&}t/|dk(y)z Create a new Connection object, using the given OpenSSL.SSL.Context instance and socket. :param context: An SSL Context to use for this connection :param socket: The socket to use for transport layer "context must be a Context instanceNr)r>rwr@rSSL_newrr5rSSL_free_ssl SSL_set_modeSSL_MODE_AUTO_RETRYrrCrrrrr#_socketBIO_new BIO_s_mem _into_sslrrX _from_ssl SSL_set_bio SSL_set_fdr)rrsocketr.rs rrzConnection.__init__s'7+@A All7++,GGC/ $))T%=%=>  +/' &44 ' 8 8(/'F'F$%,%B%B"+/dii( >DL!\\$..*:;DN DNNdii7 8!\\$..*:;DN DNNdii7 8   TYY G!DN!DN!DL ,T\\:J J!O ,rc|j&td|jjd|dt |j|S)zy Look up attributes on the wrapped socket object if they are not found on the Connection object. 'z' object has no attribute ')rAttributeError __class__rr}rnames r __getattr__zConnection.__getattr__sB <<  >>**D2  4<<. .rc:|jj$|jjj|jj$|jjj|jj$|jjjt j ||}|t jk(r t|t jk(r t|t jk(r t|t jk(r t|t jk(rt j dk(rf|dkrUt"dk(rt%j&d}nt$j(}|dk7rt+|t-j.|t+ddt1y|t j2k(rt j dk7rt j }t j4|}t j6rk(ryt1y)Nrwin32rgzUnexpected EOF) rrrrrr SSL_get_errorSSL_ERROR_WANT_READroSSL_ERROR_WANT_WRITErpSSL_ERROR_ZERO_RETURNrrSSL_ERROR_WANT_X509_LOOKUPrqSSL_ERROR_SYSCALLERR_peek_errorrr5 getwinerrorerrnorsrrr SSL_ERROR_SSLERR_GET_REASON-Cryptography_HAS_UNEXPECTED_EOF_WHILE_READINGr"SSL_R_UNEXPECTED_EOF_WHILE_READINGERR_clear_errorSSL_ERROR_NONE)rr.r0rr peeked_errorreasons r_raise_ssl_errorzConnection._raise_ssl_errors == ' ' 3 MM ( ( 9 9 ; == , , 8 MM - - > > @ == % % 1 MM & & 7 7 9""3/ D,, ,/ ! d// / " " d00 0!# # d55 5%' ' d,, ,""$)A:7* $ 0 0 21 5 $ z*5)--2FGG"2'788%& d(( (T-@-@-Ba-G ..0L((6FAAdEEE$$&"2'788$& d)) )  "rc|jS)zh Retrieve the :class:`Context` object associated with this :class:`Connection`. )rrs r get_contextzConnection.get_context+s }}rct|ts tdtj|j |j ||_y)z Switch this connection to a new session context. :param context: A :class:`Context` instance giving the new session context to use. rN)r>rwr@rSSL_set_SSL_CTXrr)rrs r set_contextzConnection.set_context2s;'7+@A A TYY(8(89 rctj|jtj}|tj k(ryt j |S)z Retrieve the servername extension value if provided in the client hello message, or None if there wasn't one. :return: A byte string giving the server name or :data:`None`. .. versionadded:: 0.13 N)rSSL_get_servernamerTLSEXT_NAMETYPE_host_namer5rXrrs rget_servernamezConnection.get_servername?sC&& IIt55  499 {{4  rct|ts td|>d|_d|_t j |j|tjyt|s tdt||_|jj|_t j |j||jy)z Override the Context object's verification flags for this specific connection. See :py:meth:`Context.set_verify` for details. r$Nr) r>rir@rrrSSL_set_verifyrr5rXrrr2r.s rr/zConnection.set_verifyPs $$56 6  "&D $(D !    4 ;H% ;<<"/"9D $($7$7$@$@D !    41F1F Grc@tj|jS)z Retrieve the Connection object's verify mode, as set by :meth:`set_verify`. :return: The verify mode )rSSL_get_verify_moderrs rr6zConnection.get_verify_modeds'' 22rct|ts tdtj|j |j }|s tyyr)r>rr@rSSL_use_certificaterrrrs rrzConnection.use_certificatemsB$%;< <--diiD  "rct|ts tdtj|j |j }|s|jjyyr) r>rr@rSSL_use_PrivateKeyrrrr rs rrzConnection.use_privatekey|sL$%:; ;,,TYY C  MM 5 5 7rcDtj|j|y)aK For DTLS, set the maximum UDP payload size (*not* including IP/UDP overhead). Note that you might have to set :data:`OP_NO_QUERY_MTU` to prevent OpenSSL from spontaneously clearing this. :param mtu: An integer giving the maximum transmission unit. .. versionadded:: 21.1 N)r SSL_set_mtur)rmtus rset_ciphertext_mtuzConnection.set_ciphertext_mtus C(rcvttds tdtj|jS)a  For DTLS, get the maximum size of unencrypted data you can pass to :meth:`write` without exceeding the MTU (as passed to :meth:`set_ciphertext_mtu`). :return: The effective MTU as an integer. .. versionadded:: 21.1 DTLS_get_data_mtuz requires OpenSSL 1.1.1 or better)hasattrrrrrrs rget_cleartext_mtuzConnection.get_cleartext_mtus0t01%&HI I%%dii00rct|ts tdd|vr tdtj|j |y)z Set the value of the servername extension to send in the client hello. :param name: A byte string giving the name. .. versionadded:: 0.13 zname must be a byte stringzname must not contain NUL byteN)r>r?r@rSSL_set_tlsext_host_namerrs rset_tlsext_host_namezConnection.set_tlsext_host_namesC$&89 9 d]<= = %%dii6rc@tj|jS)z Get the number of bytes that can be safely read from the SSL buffer (**not** the underlying transport buffer). :return: The number of bytes available in the receive buffer. )r SSL_pendingrrs rpendingzConnection.pendings **rc2td|}tj|5}t|dkDr t dt j |j|t|}|j|j||cdddS#1swYyxYw)a Send data on the connection. NOTE: If you get one of the WantRead, WantWrite or WantX509Lookup exceptions on this, you have to call the method again with the SAME buffer. :param buf: The string, buffer or memoryview to send :param flags: (optional) Included for compatibility with the socket API, the value is ignored :return: The number of bytes written r z,Cannot send more than 2**31-1 bytes at once.N) rr5 from_bufferrBr~r SSL_writerr)rr flagsr]r0s rsendzConnection.sends&eS1   c " d3x*$ B^^DIItSY?F  ! !$))V 4   s A!B  Bc @td|}tj|5}t|}d}|rWt j |j ||zt|d}|j|j |||z }||z}|rW|cdddS#1swYyxYw)a Send "all" data on the connection. This calls send() repeatedly until all data is sent. If an error occurs, it's impossible to tell how much data has been sent. :param buf: The string, buffer or memoryview to send :param flags: (optional) Included for compatibility with the socket API, the value is ignored :return: The number of bytes written r rrN) rr5rrBrrrminr)rr rr] left_to_send total_sentr0s rsendallzConnection.sendalls&eS1   c " ds8LJIItj0#lJ2O%%dii8f$ &    sA&B BBc4td|}|5|tjzr"tj|j ||}n!tj |j ||}|j|j |tj||ddS)a Receive data on the connection. :param bufsiz: The maximum number of bytes to read :param flags: (optional) The only supported flag is ``MSG_PEEK``, all other flags are ignored. :return: The string read from the Connection char[]N) _no_zero_allocatorrMSG_PEEKrSSL_peekrSSL_readrr5r=)rbufsizrr r0s rrecvzConnection.recvsw!62  !8]]499c6:F]]499c6:F dii0{{3'**rc| t|}nt|t|}td|}|5|tjzr"t j |j||}n!t j|j||}|j|j|ttj|||d||S)ae Receive data on the connection and copy it directly into the provided buffer, rather than creating a new string. :param buffer: The buffer to copy into. :param nbytes: (optional) The maximum number of bytes to read into the buffer. If not present, defaults to the size of the buffer. If larger than the size of the buffer, is reduced to the size of the buffer. :param flags: (optional) The only supported flag is ``MSG_PEEK``, all other flags are ignored. :return: The number of bytes read into the buffer. Nr) rBrrrrrrrr r memoryviewr5r=)rr=nbytesrr r0s r recv_intozConnection.recv_into s >[FV-F !62  !8]]499c6:F]]499c6:F dii0 %T[[f%=>w rctj|ritj|r ttj|r t tj |r tdtdty)NBIO_should_io_specialzunknown bio failure) rBIO_should_retryBIO_should_readroBIO_should_writerpr(r~r)rrBr0s r_handle_bio_errorszConnection._handle_bio_errors2so   %##C(#o%&&s+$&&++C0!!899!!677 ! "rc4|j tdt|ts tdt d|}t j |j||}|dkr|j|j|tj||ddS)a If the Connection was created with a memory BIO, this method can be used to read bytes from the write end of that memory BIO. Many Connection methods will add bytes which must be read in this manner or the buffer will eventually fill up and the Connection will be able to take no further actions. :param bufsiz: The maximum number of bytes to read :return: The string read. NConnection sock was not Nonezbufsiz must be an integerrr) rr@r>rirrBIO_readr,r5r=)rr!r r0s rbio_readzConnection.bio_readDs >> !:; ;&#&78 8 62t~~sF; Q;  # #DNNF ;{{3'**rc8td|}|j tdtj|5}t j |j|t|}|dkr|j|j||cdddS#1swYyxYw)aj If the Connection was created with a memory BIO, this method can be used to add bytes to the read end of that memory BIO. The Connection can then read the bytes (for example, in response to a call to :meth:`recv`). :param buf: The string to put into the memory BIO. :return: The number of bytes written r Nr.r) rrr@r5rr BIO_writerBr,)rr r]r0s r bio_writezConnection.bio_write\s&eS1 >> !:; ;   c " d^^DNND#d)DF{''?    s A BBc||js,ttj|jdk(yy)z Renegotiate the session. :return: True if the renegotiation can be started, False otherwise :rtype: bool rTF)renegotiate_pendingrrSSL_renegotiaterrs r renegotiatezConnection.renegotiateqs2'') D00;q@ Arcztj|j}|j|j|y)a Perform an SSL handshake (usually called after :meth:`renegotiate` or one of :meth:`set_accept_state` or :meth:`set_connect_state`). This can raise the same exceptions as :meth:`send` and :meth:`recv`. :return: None. N)rSSL_do_handshakerrrr0s r do_handshakezConnection.do_handshake}s,&&tyy1 dii0rcFtj|jdk(S)z Check if there's a renegotiation in progress, it will return False once a renegotiation is finished. :return: Whether there's a renegotiation in progress :rtype: bool r)rSSL_renegotiate_pendingrrs rr5zConnection.renegotiate_pendings++DII6!;;rc@tj|jS)z Find out the total number of renegotiations. :return: The number of renegotiations. :rtype: int )rSSL_total_renegotiationsrrs rtotal_renegotiationszConnection.total_renegotiationss,,TYY77rcvtj|j|jj |S)a4 Call the :meth:`connect` method of the underlying socket and set up SSL on the socket, using the :class:`Context` object supplied to this :class:`Connection` object at creation. :param addr: A remote address :return: What the socket's connect method returns )rSSL_set_connect_staterrconnect)raddrs rrCzConnection.connects+ ""499-||##D))rc^|jj}|j||S)a Call the :meth:`connect_ex` method of the underlying socket and set up SSL on the socket, using the Context object supplied to this Connection object at creation. Note that if the :meth:`connect_ex` method of the socket doesn't return 0, SSL won't be initialized. :param addr: A remove address :return: What the socket's connect_ex method returns )r connect_exset_connect_state)rrDrFs rrFzConnection.connect_exs*\\,,   $rc|jj\}}t|j|}|j ||fS)a Call the :meth:`accept` method of the underlying socket and set up SSL on the returned socket, using the Context object supplied to this :class:`Connection` object at creation. :return: A *(conn, addr)* pair where *conn* is the new :class:`Connection` object created, and *address* is as returned by the socket's :meth:`accept`. )racceptrxrset_accept_state)rclientrDrLs rrIzConnection.accepts@||**, $--0 d|rctj} tj|j|}tj||j |j j |j|jj |dk(r t|dkr|j|j|yy#tj|wxYw)z Call the OpenSSL function DTLSv1_listen on this connection. See the OpenSSL manual for more details. :return: None Nr) r BIO_ADDR_new DTLSv1_listenr BIO_ADDR_freerrrror)rbio_addrr0s rrNzConnection.DTLSv1_listens$$& )'' 8> !:; ; ##DNNA6rctj|j}|dkr|j|j|y|dkDryy)aQ Send the shutdown message to the Connection. :return: True if the shutdown completed successfully (i.e. both sides have sent closure alerts), False otherwise (in which case you call :meth:`recv` or :meth:`send` when the connection becomes readable/writeable). rTFN)r SSL_shutdownrrr:s rshutdownzConnection.shutdown s@""499- A:  ! !$))V 4 aZrcg}tD]k}tj|j|}|tj k(r|S|j t j|jdm|S)z Retrieve the list of ciphers used by the Connection object. :return: A list of native cipher strings. utf-8) rrSSL_get_cipher_listrr5rXr&rr)rciphersir0s rrQzConnection.get_cipher_list so  @A--dii;F" NN4;;v.55g> ?  @ rctj|j}|tjk(rgSg}t tj |D]}tj||}tj|}t|tjk7tjt}tj|tj|_|j||S)a Get CAs whose certificates are suggested for client authentication. :return: If this is a server connection, the list of certificate authorities that will be sent or has been sent to the client, as controlled by this :class:`Connection`'s :class:`Context`. If this is a client connection, the list will be empty until the connection with the server is established. .. versionadded:: 0.10 )rSSL_get_client_CA_listrr5rXrangesk_X509_NAME_numsk_X509_NAME_valuerVrrrrrYrWr&)rca_namesr0rbrrpynames rget_client_ca_listzConnection.get_client_ca_list) s..tyy9 tyy It,,X67 "A**8Q7D%%d+D DDII- .%%h/F774)<)<=FL MM& ! " rctd)z The makefile() method is not implemented, since there is no dup semantics for SSL connections :raise: NotImplementedError z1Cannot make file object of OpenSSL.SSL.Connectionrrrrs rmakefilezConnection.makefileF s" ?  rc|jS)zr Retrieve application data as set by :meth:`set_app_data`. :return: The application data rxrs rryzConnection.get_app_dataQ rzrc||_y)zg Set application data :param data: The application data :return: None Nrxr|s rr}zConnection.set_app_dataY r~rc@tj|jS)z Get the shutdown state of the Connection. :return: The shutdown state, a bitvector of SENT_SHUTDOWN, RECEIVED_SHUTDOWN. )rSSL_get_shutdownrrs r get_shutdownzConnection.get_shutdownb s$$TYY//rczt|ts tdtj|j |y)z Set the shutdown state of the Connection. :param state: bitvector of SENT_SHUTDOWN, RECEIVED_SHUTDOWN. :return: None zstate must be an integerN)r>rir@rSSL_set_shutdownr)rstates r set_shutdownzConnection.set_shutdownk s.%%67 7 dii/rcftjtj|jS)z Retrieve a verbose string detailing the state of the Connection. :return: A string representing the state :rtype: bytes )r5rrSSL_state_string_longrrs rget_state_stringzConnection.get_state_stringw s"{{455dii@AArcntj|j}|tjk(rytj |jtjd}t |dkDtd|}tj |j||tj||ddS)z Retrieve the random value used with the server hello message. :return: A string representing the state Nrr<) rSSL_get_sessionrr5rXSSL_get_server_randomrrr=rsessionlengthoutps r server_randomzConnection.server_random s &&tyy1 dii ++DIItyy!D #!"3V< ""499dF;{{4(++rcntj|j}|tjk(rytj |jtjd}t |dkDtd|}tj |j||tj||ddS)z Retrieve the random value used with the client hello message. :return: A string representing the state Nrr<) rr{rr5rXSSL_get_client_randomrrr=r}s r client_randomzConnection.client_random s &&tyy1 dii ++DIItyy!D #!"3V< ""499dF;{{4(++rcFtj|j}|tjk(rytj |tjd}t |dkDtd|}tj |||tj||ddS)zz Retrieve the value of the master key for this session. :return: A string representing the state Nrr<) rr{rr5rXSSL_SESSION_get_master_keyrrr=r}s r master_keyzConnection.master_key s &&tyy1 dii 00$))QG #!"3V< ''v>{{4(++rc td|}tj}d}d}||}t|}d}t j |j |||t||||}t|dk(tj||ddS)aH Obtain keying material for application use. :param: label - a disambiguating label string as described in RFC 5705 :param: olen - the length of the exported key material in bytes :param: context - a per-association context value :return: the exported key material bytes or None r<rNr) rr5rXrBrSSL_export_keying_materialrrr=) rlabelolenrr context_buf context_len use_contextsuccesss rexport_keying_materialz!Connection.export_keying_material s""3T:ii    !Kg,KK11 II    J      1 %{{4&q))rc:|jj|i|S)z Call the :meth:`shutdown` method of the underlying socket. See :manpage:`shutdown(2)`. :return: What the socket's shutdown() method returns )rr]rls r sock_shutdownzConnection.sock_shutdown s %t||$$d5f55rctj|j}|tjk7r*tj |t j|Sy)za Retrieve the local certificate (if any) :return: The local certificate N)rSSL_get_certificaterr5rXrrrrr*s rget_certificatezConnection.get_certificate sF '' 2 499    T "**40 0rctj|j}|tjk7rt j |Sy)zi Retrieve the other side's certificate (if any) :return: The peer's certificate N)rSSL_get_peer_certificaterr5rXrrrs rget_peer_certificatezConnection.get_peer_certificate s8 ,,TYY7 499 **40 0rcFg}ttj|D]}}tj||}t |t j k7tj|}t |dk\tj|}|j||S)zb Internal helper to convert a STACK_OF(X509) to a list of X509 instances. r) rer sk_X509_num sk_X509_valuerr5rXrrrr&) cert_stackr0rbr*rDpycerts r_cert_stack_to_listzConnection._cert_stack_to_list s t'' 34 "A%%j!4D DDII- .""4(C C1H %,,T2F MM& !  " rctj|j}|tjk(ry|j |S)z Retrieve the other side's certificate (if any) :return: A list of X509 instances giving the peer's certificate chain, or None if it does not have one. N)rSSL_get_peer_cert_chainrr5rXrrrs rget_peer_cert_chainzConnection.get_peer_cert_chain s811$))<  "'' 33rctj|j}|tjk(ry|j |S)a Retrieve the verified certificate chain of the peer including the peer's end entity certificate. It must be called after a session has been successfully established. If peer verification was not successful the chain may be incomplete, invalid, or None. :return: A list of X509 instances giving the peer's verified certificate chain, or None if it does not have one. .. versionadded:: 20.0 N)rSSL_get0_verified_chainrr5rXrrs rget_verified_chainzConnection.get_verified_chain s811$))<  "'' 33rc@tj|jS)z Checks if more data has to be read from the transport layer to complete an operation. :return: True iff more data has to be read )r SSL_want_readrrs r want_readzConnection.want_read s!!$)),,rc@tj|jS)z Checks if there is data to write to the transport layer to complete an operation. :return: True iff there is data to write )rSSL_want_writerrs r want_writezConnection.want_write& s""499--rcBtj|jy)z Set the connection to work in server mode. The handshake will be handled automatically by read/write. :return: None N)rSSL_set_accept_staterrs rrJzConnection.set_accept_state/ s !!$)),rcBtj|jy)z Set the connection to work in client mode. The handshake will be handled automatically by read/write. :return: None N)rrBrrs rrGzConnection.set_connect_state8 s ""499-rctj|j}|tjk(ryt j t }tj|tj|_ |S)z Returns the Session currently used. :return: An instance of :class:`OpenSSL.SSL.Session` or :obj:`None` if no session exists. .. versionadded:: 0.14 N) rSSL_get1_sessionrr5rXrvrrSSL_SESSION_free_session)rr~ pysessions r get_sessionzConnection.get_sessionA sT'' 2 dii OOG, !WWWd.C.CD rct|ts tdtj|j |j }t|dk(y)z Set the session to be used when the TLS/SSL connection is established. :param session: A Session instance representing the session to use. :returns: None .. versionadded:: 0.14 z"session must be a Session instancerN)r>rvr@rSSL_set_sessionrrr)rr~r0s r set_sessionzConnection.set_sessionR sB'7+@A A%%dii1A1AB! $rctjdd}||j|d}|dk(rytd|}||j||tj||ddS)a Helper to implement :meth:`get_finished` and :meth:`get_peer_finished`. :param function: Either :data:`SSL_get_finished`: or :data:`SSL_get_peer_finished`. :return: :data:`None` if the desired message has not yet been received, otherwise the contents of the message. :rtype: :class:`bytes` or :class:`NoneType` rrN)r5rArrr=)rfunctionemptyrr s r_get_finished_messagez Connection._get_finished_messagea sb01% 5!, 19 40C&{{3%a((rc@|jtjS)a Obtain the latest TLS Finished message that we sent. :return: The contents of the message or :obj:`None` if the TLS handshake has not yet completed. :rtype: :class:`bytes` or :class:`NoneType` .. versionadded:: 0.15 )rrSSL_get_finishedrs r get_finishedzConnection.get_finished s))$*?*?@@rc@|jtjS)a! Obtain the latest TLS Finished message that we received from the peer. :return: The contents of the message or :obj:`None` if the TLS handshake has not yet completed. :rtype: :class:`bytes` or :class:`NoneType` .. versionadded:: 0.15 )rrSSL_get_peer_finishedrs rget_peer_finishedzConnection.get_peer_finished s))$*D*DEErctj|j}|tjk(rytj tj |}|jdS)a Obtain the name of the currently used cipher. :returns: The name of the currently used cipher or :obj:`None` if no connection has been established. :rtype: :class:`unicode` or :class:`NoneType` .. versionadded:: 0.15 Nr_)rSSL_get_current_cipherrr5rXrSSL_CIPHER_get_namer)rcipherrs rget_cipher_namezConnection.get_cipher_name sO,,TYY7 TYY ;;t77?@D;;w' 'rctj|j}|tjk(rytj |tjS)a. Obtain the number of secret bits of the currently used cipher. :returns: The number of secret bits of the currently used cipher or :obj:`None` if no connection has been established. :rtype: :class:`int` or :class:`NoneType` .. versionadded:: 0.15 N)rrrr5rXSSL_CIPHER_get_bits)rrs rget_cipher_bitszConnection.get_cipher_bits s>,,TYY7 TYY ++FDII> >rctj|j}|tjk(rytj tj |}|jdS)a% Obtain the protocol version of the currently used cipher. :returns: The protocol name of the currently used cipher or :obj:`None` if no connection has been established. :rtype: :class:`unicode` or :class:`NoneType` .. versionadded:: 0.15 Nr_)rrrr5rXrSSL_CIPHER_get_versionr)rrrs rget_cipher_versionzConnection.get_cipher_version sO,,TYY7 TYY kk$"="=f"EFG>>'* *rctjtj|j}|j dS)a> Retrieve the protocol version of the current connection. :returns: The TLS version of the current connection, for example the value for TLS 1.2 would be ``TLSv1.2``or ``Unknown`` for connections that were not successfully established. :rtype: :class:`unicode` r_)r5rrSSL_get_versionrrrs rget_protocol_version_namez$Connection.get_protocol_version_name s0++d22499=>~~g&&rcDtj|j}|S)a  Retrieve the SSL or TLS protocol version of the current connection. :returns: The TLS version of the current connection. For example, it will return ``0x769`` for connections made over TLS version 1. :rtype: :class:`int` )r SSL_versionrrs rget_protocol_versionzConnection.get_protocol_version s""499-rc  |s tddjtjd|D}t j d|}t tj|j|t|dk(y)ah Specify the client's ALPN protocol list. These protocols are offered to the server during protocol negotiation. :param protos: A list of the protocols to be offered to the server. This list should be a Python list of bytestrings representing the protocols to offer, e.g. ``[b'http/1.1', b'spdy/2']``. rrc3JK|]}tt|f|fywrrrs rrz-Connection.set_alpn_protos.. rrr<rN) r~rrrr5rArrSSL_set_alpn_protosrrBrs rrzConnection.set_alpn_protos ssFG G88   FvF F  HH.9   $ $TYY 3x= IQ N rctjd}tjd}tj|j|||sytj |d|dddS)z Get the protocol that was negotiated by ALPN. :returns: A bytestring of the protocol name. If no protocol has been negotiated yet, returns an empty bytestring. rfzunsigned int *rrN)r5rArSSL_get0_alpn_selectedrr=)rr]data_lens rget_alpn_proto_negotiatedz$Connection.get_alpn_proto_negotiated s\xx*+88,- ##DIItX>{{47HQK033rc|tj|jtj}t |dk(y)a Called to request that the server sends stapled OCSP data, if available. If this is not called on the client side then the server will not send OCSP data. Should be used in conjunction with :meth:`Context.set_ocsp_client_callback`. rN)rSSL_set_tlsext_status_typerTLSEXT_STATUSTYPE_ocspr)rrs r request_ocspzConnection.request_ocsp s1 , , IIt22  a rr)r)NN)Mrrrr r#rrrrrrr/r6rrrrr rrwriterr"readr&r,r0r3r7r;r5r@rCrFrIrNrUrWrZr]rQrjrmryr}rrrvryrrrrrrr staticmethodrrrrrrJrGrrrrrrrrrrrrrrrrrrxrxs*,8-t /5#n  !"H(3 # 8 ) 17 +4 E:+" D#J#$+0*  1<8 *   54$   7" :  0 0B ,, , *<6     44&-.-." % )D A F("? +" '     D44" !rrx)rrrr functoolsrr itertoolsrrsysrweakrefr OpenSSL._utilr r r _exception_from_error_queuer r5r rr _make_assertrrrrrrOpenSSL.cryptorrrrrr__all__rrrrrr rr!rr"rSSL_SENT_SHUTDOWNr#SSL_RECEIVED_SHUTDOWNr$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3rSSL_OP_NO_SSLv2r4SSL_OP_NO_SSLv3r5SSL_OP_NO_TLSv1r6SSL_OP_NO_TLSv1_1r7SSL_OP_NO_TLSv1_2r8SSL_OP_NO_TLSv1_3rr&SSL_MODE_RELEASE_BUFFERSr9SSL_OP_SINGLE_DH_USEr:SSL_OP_SINGLE_ECDH_USEr;SSL_OP_EPHEMERAL_RSAr<SSL_OP_MICROSOFT_SESS_ID_BUGr=SSL_OP_NETSCAPE_CHALLENGE_BUGr>'SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUGr?"SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUGr@!SSL_OP_MICROSOFT_BIG_SSLV3_BUFFERrASSL_OP_MSIE_SSLV2_RSA_PADDINGrBSSL_OP_SSLEAY_080_CLIENT_DH_BUGrCSSL_OP_TLS_D5_BUGrDSSL_OP_TLS_BLOCK_PADDING_BUGrE"SSL_OP_DONT_INSERT_EMPTY_FRAGMENTSrFSSL_OP_CIPHER_SERVER_PREFERENCErGSSL_OP_TLS_ROLLBACK_BUGrHSSL_OP_PKCS1_CHECK_1rISSL_OP_PKCS1_CHECK_2rJSSL_OP_NETSCAPE_CA_DN_BUGrK&SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUGrLSSL_OP_NO_COMPRESSIONrMSSL_OP_NO_QUERY_MTUrNSSL_OP_COOKIE_EXCHANGErOSSL_OP_NO_TICKETrPSSL_OP_NO_RENEGOTIATIONrSSL_OP_IGNORE_UNEXPECTED_EOFr SSL_OP_ALLrQSSL_VERIFY_PEERrRSSL_VERIFY_FAIL_IF_NO_PEER_CERTrSSSL_VERIFY_CLIENT_ONCErTSSL_VERIFY_NONErUSSL_SESS_CACHE_OFFrVSSL_SESS_CACHE_CLIENTrWSSL_SESS_CACHE_SERVERrXSSL_SESS_CACHE_BOTHrYSSL_SESS_CACHE_NO_AUTO_CLEARrZ!SSL_SESS_CACHE_NO_INTERNAL_LOOKUPr[ SSL_SESS_CACHE_NO_INTERNAL_STOREr\SSL_SESS_CACHE_NO_INTERNALr]r^r_r`rarbrcrdrerfrgrhrirjrkrlrmryrrrrr%rnrrrorprqrrrsr robjectrtr9rTrcrorurrrurCryptography_HAS_ALPNrr}rrvrwrxrrrrs $"'   c L44#'#7#77.!%!4!44%)%:%::?+++ j%)%:%::?&& ..      $$L$$L((N((N((N"" "" "" && &&  **M NN?#44,,00,,<< >>00$"&!H!H $ F F >>"BB&& <<!%!H!H"BB22,,,,66//#..**00$$  66 NN() #@@ NN-. "" "BB00"" ((....**<< $ F F#DD88$$""         **,,,,,,....4422gLgLV "I"LI :EBu% E  U  %  e  5 ((8% ,% P"8: 0: z@I 8@IF8I 88Iv $< . ": &(3!2  4 " D+T24O   R R jy!y![0LLNNN"  J    sH