Ϫf$ddlmZddlZddlmZddlmZddlmZddl m Z ddl m Z m Z ddlmZmZdd lmZddlZdd lmZmZmZmZdd lmZdd lmZmZdd lm Z ddl!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*m+Z+ddl,m-Z-ddl.m/Z/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6GddeZ7e7jpejre7jtejve7jxejze7j|ej~e7jeAeddiZBdZCGddeDZEdZFdZGdZHd ZIeI\ZJZKZLGd!d"eZMeMjeMjz eM_Od#ZPd$d$d%d%d&d&d'd'd(d(d)d)d*d+ ZQGd,d-e eReSfZTeTZUGd.d/ZVd0ZWGd1d2eVZXGd3d4eVZYGd5d6eXZZGd7d8Z[Gd9d:e[Z\Gd;dZ^d?Z_e e]Gd@dAZ`dBZadCZbe e'GdDdEZc d_ddFdGZde e(GdHdIZee0edJdKdddLeejee_fe0edJdKdddLeejee_ge e&ejdMdMNGdOdPZiedQRdSZjedTRdUZke e%GdVdWZleljdXZndYZoGdZd[ZpGd\d]Zqd^Zry)`) annotationsN)hexlify) lru_cachemd5)Dict) Interface implementer)SSLcrypto)lib) FlagConstantFlags NamedConstantNames)Version) isIPAddress isIPv6Address)Deferred)CertificateError VerifyError)IAcceptableCiphersICipherIOpenSSLClientConnectionCreatorIOpenSSLContextFactory)logutil) nativeString)_mutuallyExclusiveArguments deprecated)Failure) secureRandom) _idnaBytescVeZdZdZeZeZeZeZeZ y) TLSVersionzD TLS versions that we can negotiate with the client/server. N) __name__ __module__ __qualname____doc__rSSLv3TLSv1_0TLSv1_1TLSv1_2TLSv1_3=/usr/lib/python3/dist-packages/twisted/internet/_sslverify.pyr&r&'s, OEoGoGoGoGr1r& OP_NO_TLSv1_3cttj}|d|j|Dcgc]}|}}|r1|j ||j|dDcgc]}|c}|Scc}wcc}w)a Given a pair of L{TLSVersion} constants, figure out what versions we want to disable (as OpenSSL is an exclusion based API). @param oldest: The oldest L{TLSVersion} we want to allow. @type oldest: L{TLSVersion} constant @param newest: The newest L{TLSVersion} we want to allow, or L{None} for no upper limit. @type newest: L{TLSVersion} constant or L{None} @return: The versions we want to disable. @rtype: L{list} of L{TLSVersion} constants. N)listr& iterconstantsindexextend)oldestnewestversionsxexcludedVersionss r2_getExcludedTLSProtocolsr>?s{J,,./H#+,DhnnV.D#EFaFF HX^^F5K5M,N Oq OP  G!Ps A4" A9ceZdZdZy)SimpleVerificationErrorz/ Not a very useful verification error. N)r'r(r)r*r0r1r2r@r@Wsr1r@c|jjj}||k7r#tt |dzt |zy)a Check only the common name in the certificate presented by the peer and only for an exact match. This is to provide I{something} in the way of hostname verification to users who haven't installed C{service_identity}. This check is overly strict, relies on a deprecated TLS feature (you're supposed to ignore the commonName if the subjectAlternativeName extensions are present, I believe), and lots of valid certificates will fail. @param connection: the OpenSSL connection to verify. @type connection: L{OpenSSL.SSL.Connection} @param hostname: The hostname expected by the user. @type hostname: L{unicode} @raise twisted.internet.ssl.VerificationError: if the common name and hostname don't match. z!=N)get_peer_certificate get_subject commonNamer@repr) connectionhostnamerDs r2simpleVerifyHostnamerH]sL(002>>@KKJX%d:&6&=X&NOOr1ctd)a5 Always fails validation of IP addresses @param connection: the OpenSSL connection to verify. @type connection: L{OpenSSL.SSL.Connection} @param hostname: The hostname expected by the user. @type hostname: L{unicode} @raise twisted.internet.ssl.VerificationError: Always raised z&Cannot verify certificate IP addresses)r@)rFrGs r2simpleVerifyIPAddressrJvs ""J KKr1cLd|jdddD\}}||fdk\S)z Check pyOpenSSL version string whether we can use it for host verification. @param version: A pyOpenSSL version string. @type version: L{str} @rtype: L{bool} c32K|]}t|ywN)int).0parts r2 z#_usablePyOpenSSL..sA$CIA.N)r )split)versionmajorminors r2_usablePyOpenSSLrZs2B'--*W $$r1cd} ddlm}ddlm}m}|||fS#t $r9}t jdt|zdz|ztddYd }~nd }~wwxYwtttfS) a Determine if C{service_identity} is installed. If so, use it. If not, use simplistic and incorrect checking as implemented in L{simpleVerifyHostname}. @return: 2-tuple of (C{verify_hostname}, C{VerificationError}) @rtype: L{tuple} zWithout the service_identity module, Twisted can perform only rudimentary TLS client hostname verification. Many valid certificate/hostname mappings may be rejected.r)VerificationError)verify_hostnameverify_ip_addresszHYou do not have a working installation of the service_identity module: 'z'. Please install it from and make sure all of its dependencies are satisfied. )categoryfilenamelinenoN) service_identityr\service_identity.pyopensslr]r^ ImportErrorwarnings warn_explicitstr UserWarningrHrJr@) whatsWrongr\r]r^es r2_selectVerifyImplementationrls 9  6Q 13DDD    )+.q6 25< <?I  I !    !68O OOs A/AAc0eZdZdZedZedZy)ProtocolNegotiationSupporta L{ProtocolNegotiationSupport} defines flags which are used to indicate the level of NPN/ALPN support provided by the TLS backend. @cvar NOSUPPORT: There is no support for NPN or ALPN. This is exclusive with both L{NPN} and L{ALPN}. @cvar NPN: The implementation supports Next Protocol Negotiation. @cvar ALPN: The implementation supports Application Layer Protocol Negotiation. r#rTN)r'r(r)r*rNPNALPNr0r1r2rnrns  v C  Dr1rncZtj}tjtj} |j d|tj z} |jd|tjz}|S#ttf$rY9wxYw#ttf$rY|SwxYw)ay Checks whether your versions of PyOpenSSL and OpenSSL are recent enough to support protocol negotiation, and if they are, what kind of protocol negotiation is supported. @return: A combination of flags from L{ProtocolNegotiationSupport} that indicate which mechanisms for protocol negotiation are supported. @rtype: L{constantly.FlagConstant} cyrMr0cs r2z/protocolNegotiationMechanisms..r1cyrMr0rss r2ruz/protocolNegotiationMechanisms..rvr1) rn NOSUPPORTr Context SSLv23_METHODset_npn_advertise_callbackroAttributeErrorNotImplementedErrorset_alpn_select_callbackrp)supportctxs r2protocolNegotiationMechanismsrs)22G ++c'' (C2 &&~6 -1113 $$^4 -222 N / 0    / 0   N  s#BBBBB*)B*rDorganizationNameorganizationalUnitName localityNamestateOrProvinceName countryName emailAddress) CNrDOrOUrLrSTrCrrc@eZdZdZdZdZdZdZd dZdZ dZ d Z y ) DistinguishedNameag Identify and describe an entity. Distinguished names are used to provide a minimal amount of identifying information about a certificate issuer or subject. They are commonly created with one or more of the following fields:: commonName (CN) organizationName (O) organizationalUnitName (OU) localityName (L) stateOrProvinceName (ST) countryName (C) emailAddress A L{DistinguishedName} should be constructed using keyword arguments whose keys can be any of the field names above (as a native string), and the values are either Unicode text which is encodable to ASCII, or L{bytes} limited to the ASCII subset. Any fields passed to the constructor will be set as attributes, accessible using both their extended name and their shortened acronym. The attribute values will be the ASCII-encoded bytes. For example:: >>> dn = DistinguishedName(commonName=b'www.example.com', ... C='US') >>> dn.C b'US' >>> dn.countryName b'US' >>> hasattr(dn, "organizationName") False L{DistinguishedName} instances can also be used as dictionaries; the keys are extended name of the fields:: >>> dn.keys() ['countryName', 'commonName'] >>> dn['countryName'] b'US' r0c N|jD]\}}t|||yrM)itemssetattr)selfkwkvs r2__init__zDistinguishedName.__init__/s'HHJ DAq D!Q  r1cTtD]}t||d}|t|||!yrM) _x509namesgetattrr)rx509namenamevalues r2 _copyFromzDistinguishedName._copyFrom3s1 +DHdD1E dE* +r1c`|jD]\}}t||t|yrM)rrr)rrrrs r2 _copyIntozDistinguishedName._copyInto9s+JJL 2DAq Haa 1 2r1c8dtj|ddzS)Nzr#)dict__repr__rs r2rzDistinguishedName.__repr__=sDMM$/"566r1cL |t|S#t$r t|wxYwrM)rKeyErrorr|)rattrs r2 __getattr__zDistinguishedName.__getattr__@s1 ' 4() ) ' & & 's #c|tvrt|dt|}t|ts|j d}|||<y)Nz' is not a valid OpenSSL X509 name fieldascii)rr| isinstancebytesencode)rrrrealAttrs r2 __setattr__zDistinguishedName.__setattr__FsH z ! D6)P!QR Rd#%'LL)EXr1c|g}d}d}t|tD]X}tj|}t t ||}t ||d}|=|j|t|fZ|dz }t|D]"\}\}}|j|dz|z||<$dj|S)zh Return a multi-line, human-readable representation of this DN. @rtype: L{str} rc4t|jSrM)setvalues)mappings r2 uniqueValuesz/DistinguishedName.inspect..uniqueValuesWsw~~'( (r1NrTz:  ) sortedrr nameToLabelmaxlenrappendr enumeraterjustjoin) rllablenrrlabelrnattribs r2inspectzDistinguishedName.inspectNs  ) Z01 3A$$Q'EUV,Fa&A}%a12  3 ! "+A, 7 Av;;v&-6AaD 7yy|r1Nreturnrh) r'r(r)r* __slots__rrrrrrrr0r1r2rrs2(TI + 27' r1rc(eZdZdZdZdZdZdZy)CertBasez Base class for public (certificate only) and private (certificate + key pair) certificates. @ivar original: The underlying OpenSSL certificate object. @type original: L{OpenSSL.crypto.X509} c||_yrMoriginal)rrs r2rzCertBase.__init__rs   r1ctt}|jt|jd|z|S)Nget_)rrrr)rsuffixdns r2 _copyNamezCertBase._copyNameus0   ? r1c$|jdS)z Retrieve the subject of this certificate. @return: A copy of the subject of this certificate. @rtype: L{DistinguishedName} subjectrrs r2 getSubjectzCertBase.getSubjectzs~~i((r1cJ|turt|jgStS)aM Convert this L{CertBase} into a provider of the given interface. @param interface: The interface to conform to. @type interface: L{zope.interface.interfaces.IInterface} @return: an L{IOpenSSLTrustRoot} provider or L{NotImplemented} @rtype: L{IOpenSSLTrustRoot} or L{NotImplemented} )IOpenSSLTrustRootOpenSSLCertificateAuthoritiesrNotImplemented)r interfaces r2 __conform__zCertBase.__conform__s$ ) )0$--A Ar1N)r'r(r)r*rrrrr0r1r2rris! ) r1rct|jd|dd}|tdj|||}|tdj||||S)a (private) Helper for L{Certificate.peerFromTransport} and L{Certificate.hostFromTransport} which checks for incompatible handle types and null certificates and raises the appropriate exception or returns the appropriate certificate object. r _certificateNz2non-TLS transport {!r} did not have {} certificatez.TLS transport {!r} did not have {} certificate)r getHandlerformat)Class transport methodNamemethodcerts r2_handleattrhelperrsY((*d:,l,KT RF ~ @ G G:   8D | < C C:   ;r1ceZdZdZddZddZeejdfdZ e Z dZ edZ edZ ed Zd Zejfdd Zd Zdd ZdZdZdZdZy) Certificatez An x509 certificate. cdj|jj|jj|j jS)Nz<{} Subject={} Issuer={}>)r __class__r'rrD getIssuerrs r2rzCertificate.__repr__sB*11 NN # # OO  ( ( NN  ' '  r1cpt|tr!|j|jk(StSrM)rrdumpr)rothers r2__eq__zCertificate.__eq__s) e[ )99;%**,. .r1r0c<|tj||g|S)zc Load a certificate from an ASN.1- or PEM-format string. @rtype: C{Class} )r load_certificate)r requestDatarargss r2loadzCertificate.loads!V,,V[AIDIIr1c@|jtjS)z\ Dump this certificate to a PEM-format data string. @rtype: L{str} )rr FILETYPE_PEMrs r2dumpPEMzCertificate.dumpPEMs yy,,--r1cB|j|tjS)z] Load a certificate from a PEM-format data string. @rtype: C{Class} )rr rrdatas r2loadPEMzCertificate.loadPEMszz$ 3 344r1ct||dS)a  Get the certificate for the remote end of the given transport. @param transport: an L{ISystemHandle} provider @rtype: C{Class} @raise CertificateError: if the given transport does not have a peer certificate. peerrrrs r2peerFromTransportzCertificate.peerFromTransport! 6::r1ct||dS)a Get the certificate for the local end of the given transport. @param transport: an L{ISystemHandle} provider; the transport we will @rtype: C{Class} @raise CertificateError: if the given transport does not have a host certificate. hostrrs r2hostFromTransportzCertificate.hostFromTransportrr1cHt|jjS)zX Get the public key for this certificate. @rtype: L{PublicKey} ) PublicKeyr get_pubkeyrs r2 getPublicKeyzCertificate.getPublicKeys 11344r1cBtj||jSrM)r dump_certificaterrrs r2rzCertificate.dumps&&vt}}==r1c6|jjS)zY Retrieve the serial number of this certificate. @rtype: L{int} )rget_serial_numberrs r2 serialNumberzCertificate.serialNumbers }}..00r1c8|jj|S)a Return a digest hash of this certificate using the specified hash algorithm. @param method: One of C{'md5'} or C{'sha'}. @return: The digest of the object, formatted as b":"-delimited hex pairs @rtype: L{bytes} )rdigest)rrs r2rzCertificate.digests}}##F++r1c djd|jjd|jjd|j zdt |j zgS)NrzCertificate For Subject:z Issuer:z Serial Number: %dz Digest: %s)rrrrrrrrs r2_inspectzCertificate._inspectshyy*!))+ ((*%(9(9(;;|DKKM::    r1c|dj|j|jjfS)z Return a multi-line, human-readable representation of this Certificate, including information about the subject, issuer, and public key. r)rrrrrs r2rzCertificate.inspect!s0 yy$--/4+<+<+>+F+F+HIJJr1c$|jdS)z Retrieve the issuer of this certificate. @rtype: L{DistinguishedName} @return: A copy of the issuer of this certificate. issuerrrs r2rzCertificate.getIssuer)s~~h''r1ctd)Nz'Possible, but doubtful we need this yet)r})r authoritiess r2optionszCertificate.options2s!"KLLr1Nr)robjectrbool)rrNrrr)r'r(r)r*rr classmethodr FILETYPE_ASN1r_loadrrrrrrrrrrrrr0r1r2rrs  (.(<(<2JJ E.55 ; ; ; ;5"(!5!5>1 ,  K(Mr1rcVeZdZdZeej fdZej fdZy)CertificateRequestz An x509 certificate request. Certificate requests are given to certificate authorities to be signed and returned resulting in an actual certificate. ctj||}t}|j|j |j |j std|d||S)NzCan't verify that request for z is self-signed.)r load_certificate_requestrrrCverifyrr)rr requestFormatreqrs r2rzCertificateRequest.load>sb--m[I   S__&'zz#..*+ >rfDTUV VSzr1cBtj||jSrM)r dump_certificate_requestrr s r2rzCertificateRequest.dumpGs..vt}}EEr1N) r'r(r)r*rr rrrr0r1r2rr6s5/5/C/C!..Fr1rceZdZdZddZdZejfdZe ejfdZ dZ dZ e dZ e d Zd Zejd fd Zejejfd Z ddZy)PrivateCertificatez. An x509 certificate and private key. c^tj|dzt|jzS)Nz with )rrrE privateKeyrs r2rzPrivateCertificate.__repr__Ps&##D)H4tDOO7LLLr1ch|j|js td||_|S)Nz1Certificate public and private keys do not match.)matchesrrr*)rr*s r2_setPrivateKeyz!PrivateCertificate._setPrivateKeySs1!!$"3"3"56QR R$ r1c<|j||j|S)z} Create a new L{PrivateCertificate} from the given certificate data and this instance's private key. )rr*r newCertDatars r2newCertificatez!PrivateCertificate.newCertificateYs yydoov>>r1cD|j||j|SrM)rr-)rrr*rs r2rzPrivateCertificate.load`s{{4(77 CCr1c~djtj||jj gS)Nr)rrrr*rrs r2rzPrivateCertificate.inspectds.yy+..t4doo6M6M6OPQQr1c|jtj|jjtjzS)zi Dump both public and private parts of a private certificate to PEM-format data. )rr rr*rs r2rzPrivateCertificate.dumpPEMgs: yy,,-0D0D   1   r1c|j|tj|tjtjS)zv Load both private and public parts of a private certificate from a chunk of PEM-format data. )rKeyPairr rrs r2rzPrivateCertificate.loadPEMps3 zz ',,tV%8%896;N;N  r1cH||j}|j|SrM)rr-)rcertificateInstancer*privcerts r2fromCertificateAndKeyPairz,PrivateCertificate.fromCertificateAndKeyPairzs$,556&&z22r1c t|jj|j}|r<|jtt |Dcgc]}|jc}t di|Scc}w)a$ Create a context factory using this L{PrivateCertificate}'s certificate and private key. @param authorities: A list of L{Certificate} object @return: A context factory. @rtype: L{CertificateOptions } r* certificate) trustRootr0)rr*rupdaterOpenSSLCertificateOptions)rrrauths r2rzPrivateCertificate.optionsse$//":": V  NN;3>?4? )3733 @sA5sha256cX|jj|j||SrM)r*certificateRequestr)rrdigestAlgorithms r2rDz%PrivateCertificate.certificateRequests'11 OO v  r1cb|j}|jj||||||SrM)rr*signCertificateRequest)rrverifyDNCallbackrr#certificateFormatrs r2rGz)PrivateCertificate.signCertificateRequests9"55         r1c\|jj|j||||SrM)r*signRequestObjectr)rrDrsecondsToExpiryrEs r2rKz$PrivateCertificate.signRequestObjects100 OO        r1Nr3rB)r'r(r)r*rr-r rr1rrrrrr:rrDrGrKr0r1r2r(r(KsM 281E1E?-3-A-ADDR   334*)/(<()rr'rTrs r2rzPublicKey.__repr__s)4>>**+1T\\^,>r1ctjtj|j}t }|j ||j S)at Compute a hash of the underlying PKey object. The purpose of this method is to allow you to determine if two certificates share the same public key; it is not really useful for anything else. In versions of Twisted prior to 15.0, C{keyHash} used a technique involving certificate requests for computing the hash that was not stable in the face of changes to the underlying OpenSSL library. @return: Return a 32-character hexadecimal string uniquely identifying this public key, I{for this version of Twisted}. @rtype: native L{str} )r dump_publickeyrrrr? hexdigest)rrawhs r2rTzPublicKey.keyHashs> ##F$8$8$--H E  {{}r1c(d|jS)NzPublic Key with Hash: rSrs r2rzPublicKey.inspects' '788r1Nr) r'r(r)r*rr,rrTrr0r1r2rrs  ! 4?*9r1rcreZdZeej fdZej fdZee ddddddZ ee ddddddZ d Z eejd fd Zej fd ZddZej d fdZej ej dd fdZ ddZdZy)r6c:|tj||SrM)r load_privatekey)rrrs r2rz KeyPair.loadsV++FD9::r1cBtj||jSrM)r dump_privatekeyrr s r2rz KeyPair.dumps%%fdmm<.verifiedCsW!?FF(" ))'  d$%  &r1)rrrrr addCallback) rrrrHrr#rIrLrEvvalrrrs `` `` ``` @@r2rGzKeyPair.signCertificateRequest,sa$#'' ]C    # & & dH %##H- -D> !r1c|j}tj}|j|j |j |j |j|j|jd|j||j||j|j|t|S)zW Sign a CertificateRequest instance, returning a Certificate instance. r)rr X509r get_issuer set_subjectrCrrgmtime_adj_notBeforegmtime_adj_notAfterset_serial_numberrr)rrrrrLrEr$rs r2rKzKeyPair.signRequestObjectWs$${{}))$//*;< *+ () !!!$   1 |, $--14  r1c tdi|}tj|j||j |||S)Nr0)DNr(r:rKr)rrrrs r2selfSignedCertzKeyPair.selfSignedCertms? X"X!;;  " "2t'9'9"'=| Ld  r1N)rBrM)r'r(r)rr rrrr rrirmrrrr}r1rrDrGrKrr0r1r2r6r6s!'!5!5;;!..= 2q!,.IJK 2q!,.IJKKK 6#__4 281E1EB')/(<(}. c$|jyrM)set_default_verify_paths)rrs r2rz(OpenSSLDefaultPaths._addCACertsToContexts((*r1Nrr0r1r2rrs  +r1rctS)aD Attempt to discover a set of trusted certificate authority certificates (or, in other words: trust roots, or root certificates) whose trust is managed and updated by tools outside of Twisted. If you are writing any client-side TLS code with Twisted, you should use this as the C{trustRoot} argument to L{CertificateOptions }. The result of this function should be like the up-to-date list of certificates in a web browser. When developing code that uses C{platformTrust}, you can think of it that way. However, the choice of which certificate authorities to trust is never Twisted's responsibility. Unless you're writing a very unusual application or library, it's not your code's responsibility either. The user may use platform-specific tools for defining which server certificates should be trusted by programs using TLS. The purpose of using this API is to respect that decision as much as possible. This should be a set of trust settings most appropriate for I{client} TLS connections; i.e. those which need to verify a server's authenticity. You should probably use this by default for any client TLS connection that you create. For servers, however, client certificates are typically not verified; or, if they are, their verification will depend on a custom, application-specific certificate authority. @since: 14.0 @note: Currently, L{platformTrust} depends entirely upon your OpenSSL build supporting a set of "L{default verify paths }" which correspond to certificate authority trust roots. Unfortunately, whether this is true of your system is both outside of Twisted's control and difficult (if not impossible) for Twisted to detect automatically. Nevertheless, this ought to work as desired by default on: - Ubuntu Linux machines with the U{ca-certificates } package installed, - macOS when using the system-installed version of OpenSSL (i.e. I{not} one installed via MacPorts or Homebrew), - any build of OpenSSL which has had certificate authority certificates installed into its default verify paths (by default, C{/usr/local/ssl/certs} if you've built your own OpenSSL), or - any process where the C{SSL_CERT_FILE} environment variable is set to the path of a file containing your desired CA certificates bundle. Hopefully soon, this API will be updated to use more sophisticated trust-root discovery mechanisms. Until then, you can follow tickets in the Twisted tracker for progress on this implementation on U{Microsoft Windows }, U{macOS }, and U{a fallback for other platforms which do not have native trust management tools }. @return: an appropriate trust settings object for your platform. @rtype: L{IOpenSSLTrustRoot} @raise NotImplementedError: if this platform is not yet supported by Twisted. At present, only OpenSSL is supported. )rr0r1r2 platformTrustrsF   r1cfd}|S)a- Wrap up an C{info_callback} for pyOpenSSL so that if something goes wrong the error is immediately logged and the connection is dropped if possible. This wrapper exists because some versions of pyOpenSSL don't handle errors from callbacks at I{all}, and those which do write tracebacks directly to stderr rather than to a supplied logging system. This reports unexpected errors to the Twisted logging system. Also, this terminates the connection immediately if possible because if you've got bugs in your verification logic it's much safer to just give up. @param wrapped: A valid C{info_callback} for pyOpenSSL. @type wrapped: L{callable} @return: A valid C{info_callback} for pyOpenSSL that handles any errors in C{wrapped}. @rtype: L{callable} c |||S#t$rBt}tj|d|j j |YywxYw)NzError during info_callback) BaseExceptionr!rerr get_app_datafailVerification)rFwhereretfwrappeds r2 infoCallbackz%_tolerateErrors..infoCallback$sS ::uc2 2 : A GGA3 4  # # % 6 6q 9 :s AAAr0)rrs` r2_tolerateErrorsrs*: r1c"eZdZdZdZdZdZy)ClientTLSOptionsa Client creator for TLS. Private implementation type (not exposed to applications) for public L{optionsForClientTLS} API. @ivar _ctx: The context to use for new connections. @type _ctx: L{OpenSSL.SSL.Context} @ivar _hostname: The hostname to verify, as specified by the application, as some human-readable text. @type _hostname: L{unicode} @ivar _hostnameBytes: The hostname to verify, decoded into IDNA-encoded bytes. This is passed to APIs which think that hostnames are bytes, such as OpenSSL's SNI implementation. @type _hostnameBytes: L{bytes} @ivar _hostnameASCII: The hostname, as transcoded into IDNA ASCII-range unicode code points. This is pre-transcoded because the C{service_identity} package is rather strict about requiring the C{idna} package from PyPI for internationalized domain names, rather than working with Python's built-in (but sometimes broken) IDNA encoding. ASCII values, however, will always work. @type _hostnameASCII: L{unicode} @ivar _hostnameIsDnsName: Whether or not the C{_hostname} is a DNSName. Will be L{False} if C{_hostname} is an IP address or L{True} if C{_hostname} is a DNSName @type _hostnameIsDnsName: L{bool} c>||_||_t|s t|r|j d|_d|_nt||_d|_|j jd|_ |jt|jy)a Initialize L{ClientTLSOptions}. @param hostname: The hostname to verify as input by a human. @type hostname: L{unicode} @param ctx: an L{OpenSSL.SSL.Context} to use for new connections. @type ctx: L{OpenSSL.SSL.Context}. rFTN) _ctx _hostnamerrr_hostnameBytes_hostnameIsDnsNamer$decode_hostnameASCIIset_info_callbackr_identityVerifyingInfoCallback)rrGrs r2rzClientTLSOptions.__init__Qs ! x M($;"*//'":D &+D #",X"6D &*D #"1188A od.Q.QRSr1cl|j}tj|d}|j||S)ap Create a TLS connection for a client. @note: This will call C{set_app_data} on its connection. If you're delegating to this implementation of this method, don't ever call C{set_app_data} or C{set_info_callback} on the returned connection, or you'll break the implementation of various features of this class. @param tlsProtocol: the TLS protocol initiating the connection. @type tlsProtocol: L{twisted.protocols.tls.TLSMemoryBIOProtocol} @return: the configured client connection. @rtype: L{OpenSSL.SSL.Connection} N)rr Connection set_app_data)r tlsProtocolrrFs r2clientConnectionForTLSz'ClientTLSOptions.clientConnectionForTLShs1 ))^^GT2  ,r1c|tjzr(|jr|j|jy|tj zr; |jrt ||jyt||jyy#t$r.t}|j}|j|YywxYw)a U{info_callback } for pyOpenSSL that verifies the hostname in the presented certificate matches the one passed to this L{ClientTLSOptions}. @param connection: the connection which is handshaking. @type connection: L{OpenSSL.SSL.Connection} @param where: flags indicating progress through a TLS handshake. @type where: L{int} @param ret: ignored @type ret: ignored N) r SSL_CB_HANDSHAKE_STARTrset_tlsext_host_namerSSL_CB_HANDSHAKE_DONEverifyHostnamerverifyIPAddressr\r!rr)rrFrrrrs r2rz/ClientTLSOptions._identityVerifyingInfoCallback}s$ 3-- -$2I2I  + +D,?,? @ S.. . .**":t/B/BC#J0C0CD / % .I&335 **1- .s"B 3B 4CCN)r'r(r)r*rrrr0r1r2rr/s@T.*.r1r)extraCertificateOptionsc<|i}| t}t|ts"td|jj z|r1|j |jj|jtd||d|}t||jS)a Create a L{client connection creator } for use with APIs such as L{SSL4ClientEndpoint }, L{connectSSL }, and L{startTLS }. @since: 14.0 @param hostname: The expected name of the remote host. This serves two purposes: first, and most importantly, it verifies that the certificate received from the server correctly identifies the specified hostname. The second purpose is to use the U{Server Name Indication extension } to indicate to the server which certificate should be used. @type hostname: L{unicode} @param trustRoot: Specification of trust requirements of peers. This may be a L{Certificate} or the result of L{platformTrust}. By default it is L{platformTrust} and you probably shouldn't adjust it unless you really know what you're doing. Be aware that clients using this interface I{must} verify the server; you cannot explicitly pass L{None} since that just means to use L{platformTrust}. @type trustRoot: L{IOpenSSLTrustRoot} @param clientCertificate: The certificate and private key that the client will use to authenticate to the server. If unspecified, the client will not authenticate. @type clientCertificate: L{PrivateCertificate} @param acceptableProtocols: The protocols this peer is willing to speak after the TLS negotiation has completed, advertised over both ALPN and NPN. If this argument is specified, and no overlap can be found with the other peer, the connection will fail to be established. If the remote peer does not offer NPN or ALPN, the connection will be established, but no protocol wil be negotiated. Protocols earlier in the list are preferred over those later in the list. @type acceptableProtocols: L{list} of L{bytes} @param extraCertificateOptions: A dictionary of additional keyword arguments to be presented to L{CertificateOptions}. Please avoid using this unless you absolutely need to; any time you need to pass an option here that is a bug in this interface. @type extraCertificateOptions: L{dict} @return: A client connection creator. @rtype: L{IOpenSSLClientConnectionCreator} z6optionsForClientTLS requires text for host names, not r<)r>acceptableProtocolsr0) rrrhrrr'r?r*rr@r getContext)rGr>clientCertificaterrcertificateOptionss r2optionsForClientTLSrsp&"$!O h $ D  )) *  &&(33<<)22 ' 3/ " H&8&C&C&E FFr1c eZdZdZej ZdZee jZ e jZ eddgddgddgddgdd gd dgdd gg dd Zd Zd ZdZdZy)r@a A L{CertificateOptions } specifies the security properties for a client or server TLS connection used with OpenSSL. @ivar _options: Any option flags to set on the L{OpenSSL.SSL.Context} object that will be created. @type _options: L{int} @ivar _cipherString: An OpenSSL-specific cipher string. @type _cipherString: L{unicode} @ivar _defaultMinimumTLSVersion: The default TLS version that will be negotiated. This should be a "safe default", with wide client and server support, vs an optimally secure one that excludes a large number of users. As of May 2022, TLSv1.2 is that safe default. @type _defaultMinimumTLSVersion: L{TLSVersion} constant Nr>requireCertificater"rrinsecurelyLowerMinimumToraiseMinimumTolowerMaximumSecurityToc |du|duk7r td||_||_tjtj ztj z|_tj|_ |tj|_ |r#|r||kDr td||jkDr|}||j}|r||kDr|}|r||kDr tdt||}|D]}|xjt|zc_ n#tj dt"d||_ |r |s td||_| d||fvr td | | |_ng|_||_||_||_||_| |_| r4|xjtj2tj4zzc_| |_| |_| r#|xjtj:zc_| |_| s#|xjtj>zc_||_ tCtjDtFtH |_%|tL}d jOd |jQtSd |j|jD|_*|jTdk(r td||j$r%tW|}nd|_d|_tY|}||_-|t]s t_d||_0y)a Create an OpenSSL context SSL connection context factory. @param privateKey: A PKey object holding the private key. @param certificate: An X509 object holding the certificate. @param method: Deprecated, use a combination of C{insecurelyLowerMinimumTo}, C{raiseMinimumTo}, or C{lowerMaximumSecurityTo} instead. The SSL protocol to use, one of C{TLS_METHOD}, C{TLSv1_2_METHOD}, or C{TLSv1_2_METHOD} (or any future method constants provided by pyOpenSSL). By default, a setting will be used which allows TLSv1.2 and TLSv1.3. Can not be used with C{insecurelyLowerMinimumTo}, C{raiseMinimumTo}, or C{lowerMaximumSecurityTo}. @param verify: Please use a C{trustRoot} keyword argument instead, since it provides the same functionality in a less error-prone way. By default this is L{False}. If L{True}, verify certificates received from the peer and fail the handshake if verification fails. Otherwise, allow anonymous sessions and sessions with certificates which fail validation. @param caCerts: Please use a C{trustRoot} keyword argument instead, since it provides the same functionality in a less error-prone way. List of certificate authority certificate objects to use to verify the peer's certificate. Only used if verify is L{True} and will be ignored otherwise. Since verify is L{False} by default, this is L{None} by default. @type caCerts: L{list} of L{OpenSSL.crypto.X509} @param verifyDepth: Depth in certificate chain down to which to verify. If unspecified, use the underlying default (9). @param requireCertificate: Please use a C{trustRoot} keyword argument instead, since it provides the same functionality in a less error-prone way. If L{True}, do not allow anonymous sessions; defaults to L{True}. @param verifyOnce: If True, do not re-verify the certificate on session resumption. @param enableSingleUseKeys: If L{True}, generate a new key whenever ephemeral DH and ECDH parameters are used to prevent small subgroup attacks and to ensure perfect forward secrecy. @param enableSessions: This allows a shortened handshake to be used when a known client reconnects to the same process. If True, enable OpenSSL's session caching. Note that session caching only works on a single Twisted node at once. Also, it is currently somewhat risky due to U{a crashing bug when using OpenSSL 1.1.1 }. @param fixBrokenPeers: If True, enable various non-spec protocol fixes for broken SSL implementations. This should be entirely safe, according to the OpenSSL documentation, but YMMV. This option is now off by default, because it causes problems with connections between peers using OpenSSL 0.9.8a. @param enableSessionTickets: If L{True}, enable session ticket extension for session resumption per RFC 5077. Note there is no support for controlling session tickets. This option is off by default, as some server implementations don't correctly process incoming empty session ticket extensions in the hello. @param extraCertChain: List of certificates that I{complete} your verification chain if the certificate authority that signed your C{certificate} isn't widely supported. Do I{not} add C{certificate} to it. @type extraCertChain: C{list} of L{OpenSSL.crypto.X509} @param acceptableCiphers: Ciphers that are acceptable for connections. Uses a secure default if left L{None}. @type acceptableCiphers: L{IAcceptableCiphers} @param dhParameters: Key generation parameters that are required for Diffie-Hellman key exchange. If this argument is left L{None}, C{EDH} ciphers are I{disabled} regardless of C{acceptableCiphers}. @type dhParameters: L{DiffieHellmanParameters } @param trustRoot: Specification of trust requirements of peers. If this argument is specified, the peer is verified. It requires a certificate, and that certificate must be signed by one of the certificate authorities specified by this object. Note that since this option specifies the same information as C{caCerts}, C{verify}, and C{requireCertificate}, specifying any of those options in combination with this one will raise a L{TypeError}. @type trustRoot: L{IOpenSSLTrustRoot} @param acceptableProtocols: The protocols this peer is willing to speak after the TLS negotiation has completed, advertised over both ALPN and NPN. If this argument is specified, and no overlap can be found with the other peer, the connection will fail to be established. If the remote peer does not offer NPN or ALPN, the connection will be established, but no protocol wil be negotiated. Protocols earlier in the list are preferred over those later in the list. @type acceptableProtocols: L{list} of L{bytes} @param raiseMinimumTo: The minimum TLS version that you want to use, or Twisted's default if it is higher. Use this if you want to make your client/server more secure than Twisted's default, but will accept Twisted's default instead if it moves higher than this value. You probably want to use this over C{insecurelyLowerMinimumTo}. @type raiseMinimumTo: L{TLSVersion} constant @param insecurelyLowerMinimumTo: The minimum TLS version to use, possibly lower than Twisted's default. If not specified, it is a generally considered safe default (TLSv1.0). If you want to raise your minimum TLS version to above that of this default, use C{raiseMinimumTo}. DO NOT use this argument unless you are absolutely sure this is what you want. @type insecurelyLowerMinimumTo: L{TLSVersion} constant @param lowerMaximumSecurityTo: The maximum TLS version to use. If not specified, it is the most recent your OpenSSL supports. You only want to set this if the peer that you are communicating with has problems with more recent TLS versions, it lowers your security when communicating with newer peers. DO NOT use this argument unless you are absolutely sure this is what you want. @type lowerMaximumSecurityTo: L{TLSVersion} constant @raise ValueError: when C{privateKey} or C{certificate} are set without setting the respective other. @raise ValueError: when C{verify} is L{True} but C{caCerts} doesn't specify any CA certificates. @raise ValueError: when C{extraCertChain} is passed without specifying C{privateKey} or C{certificate}. @raise ValueError: when C{acceptableCiphers} doesn't yield any usable ciphers for the current platform. @raise TypeError: if C{trustRoot} is passed in combination with C{caCert}, C{verify}, or C{requireCertificate}. Please prefer C{trustRoot} in new code, as its semantics are less tricky. @raise TypeError: if C{method} is passed in combination with C{tlsProtocols}. Please prefer the more explicit C{tlsProtocols} in new code. @raises NotImplementedError: If acceptableProtocols were provided but no negotiation mechanism is available. Nz5Specify neither or both of privateKey and certificatez.2s&  JJ& sALLr_zGSupplied IAcceptableCiphers yielded no usable ciphers on this platform.Tz5No support for protocol negotiation on this platform.)1 ValueErrorr*r=r OP_NO_SSLv2OP_NO_COMPRESSIONOP_CIPHER_SERVER_PREFERENCE_optionsMODE_RELEASE_BUFFERS_mode TLS_METHODr_defaultMinimumTLSVersionr>_tlsDisableFlagsrfwarnDeprecationWarningr"extraCertChainr verifyDepthr verifyOnceenableSingleUseKeysOP_SINGLE_DH_USEOP_SINGLE_ECDH_USEenableSessionsfixBrokenPeersOP_ALLenableSessionTickets OP_NO_TICKET dhParameters!_ChooseDiffieHellmanEllipticCurveOPENSSL_VERSION_NUMBER pyOpenSSLlibr _ecChooserdefaultCiphersr selectCiphers_expandCipherString _cipherStringrrr>rr}_acceptableProtocols)rr*r=rr"rrrrrrrrracceptableCiphersrr>rrrrr=rWs r2rz"OpenSSLCertificateOptions.__init__s'r $ K4$7 8TU U$& OOc33 3c6U6U U -- >..DK)n?U.U$1 "D$B$BB/=,'/+/+I+I( +03II/E,',/EE - 8(*@  , ; !1'!::  ; MM, # !DK '=   %$:{2K*K@   %"0D "$D  &"4$#6  MMS11C4J4JJ JM,,  MMSZZ 'M$8!# MMS-- -M(;  & &#    $ .  XX& &44#E4;; F&      #$   {{9'B DK&*D #))4I"  *3P3R%G %8!r1cb|jj} |d=|S#t$rY|SwxYw)N_context)__dict__copyr)rds r2riz&OpenSSLCertificateOptions.__getstate__Ns@ MM    *    s ! ..c||_yrM)r rks r2rmz&OpenSSLCertificateOptions.__setstate__Vs  r1c\|j|j|_|jS)z: Return an L{OpenSSL.SSL.Context} object. )r  _makeContextrs r2rz$OpenSSLCertificateOptions.getContextYs( ==  --/DM}}r1cF|j|j}|j|j|j |j |j t|jh|j|j |j|j|jD]}|j||jtj}|jritj }|j"r|tj$z}|j&r|tj(z}|j*j-||j/||j0|j3|j0t5t7d}|j9||j:r |j=tj>n|j=tj@|jBr/|jE|jBjFjH|jK|jLjOd|jPjS||jTrtW||jT|S)Nr),_contextFactoryr set_optionsrset_moderr=r*use_certificateuse_privatekeyradd_extra_chain_certcheck_privatekeyr VERIFY_NONEr" VERIFY_PEERrVERIFY_FAIL_IF_NO_PEER_CERTrVERIFY_CLIENT_ONCEr>r set_verifyrset_verify_depthrr"set_session_idrset_session_cache_modeSESS_CACHE_SERVERSESS_CACHE_OFFr load_tmp_dh_dhFilepathset_cipher_listrrrconfigureECDHCurver_setAcceptableProtocols)rr extraCert verifyFlagssessionIDContexts r2rz&OpenSSLCertificateOptions._makeContextas""4;;/  & TZZ    'DOO,G    0 0 1   t /!00 4 ((3 4  "oo ;;//K&&s>>> s555 NN / / 4 {#    '  !1!1 2 #<?3 +,     & &s'<'< =  & &s'9'9 :    OOD--55:: ; D..55g>? **3/  $ $ $C)B)B C r1)NNNFN TTTFFFNNNNNNNN)r'r(r)r*r ryrr rr&r/_OP_NO_TLSv1_3r.rrrrirmrrr0r1r2r@r@s(kkOH%j&8&89N * 2 2 . / ( # ) $ 1 2 ' ( 9 : / 0   " !%#+y8 y8v 8r1r@rerfrgT)frozen auto_attribsceZdZUdZded<y) OpenSSLCipherz A representation of an OpenSSL cipher. @ivar fullName: The full name of the cipher. For example C{u"ECDHE-RSA-AES256-GCM-SHA384"}. @type fullName: L{unicode} rhrN)r'r(r)r*__annotations__r0r1r2r1r1sMr1r1 )maxsizec tj|}|j| |j|j dtj|d}|j}t|dtrtd|DStd|DS#tj $rK}|j dstcYd}~S|j ddddk(rtcYd}~Sd}~wwxYw)af Expand C{cipherString} according to C{method} and C{options} to a tuple of explicit ciphers that are supported by the current platform. @param cipherString: An OpenSSL cipher string to expand. @type cipherString: L{unicode} @param method: An OpenSSL method like C{SSL.TLS_METHOD} used for determining the effective ciphers. @param options: OpenSSL options like C{SSL.OP_NO_SSLv3} ORed together. @type options: L{int} @return: The effective list of explicit ciphers that results from the arguments on the current platform. @rtype: L{tuple} of L{ICipher} rrNrTzno cipher matchc32K|]}t|ywrM)r1rOciphers r2rQz&_expandCipherString..sAv]6*ArRc3PK|]}t|jd yw)rN)r1rr7s r2rQz&_expandCipherString..sQv]6==#9:Qs$&) r ryrr&rErrorrtuplerget_cipher_listrrh) cipherStringrrrrkconncipherss r2rrs& ++f COOG  L//89 >>#t $D""$G'!*c"AAAAQQQQ! 99  vvay7N 66!9Q<?/ /7N  s/ B%%D8C>D!C>7D=C>>Dc,tfd|DS)a Caclulate the acceptable list of ciphers from the ciphers we want and the ciphers we have support for. @param wantedCiphers: The ciphers we want to use. @type wantedCiphers: L{tuple} of L{OpenSSLCipher} @param availableCiphers: The ciphers we have available to use. @type availableCiphers: L{tuple} of L{OpenSSLCipher} @rtype: L{tuple} of L{OpenSSLCipher} c3,K|] }|vs| ywrMr0)rOr8availableCipherss r2rQz!_selectCiphers..sRFvAQ7QRs )r;) wantedCiphersrCs `r2_selectCiphersrEs RmR RRr1c,eZdZdZdZdZedZy)OpenSSLAcceptableCipherszN A representation of ciphers that are acceptable for TLS connections. c$t||_yrM)r;_ciphers)rr?s r2rz!OpenSSLAcceptableCiphers.__init__s g r1c@t|jt|SrM)rErIr;)rrCs r2rz&OpenSSLAcceptableCiphers.selectCipherssdmmU3C-DEEr1c|tt|tjtjtj zS)aR Create a new instance using an OpenSSL cipher string. @param cipherString: An OpenSSL cipher string that describes what cipher suites are acceptable. See the documentation of U{OpenSSL } or U{Apache } for details. @type cipherString: L{unicode} @return: Instance representing C{cipherString}. @rtype: L{twisted.internet.ssl.AcceptableCiphers} )rrr rr OP_NO_SSLv3)clsr=s r2fromOpenSSLCipherStringz0OpenSSLAcceptableCiphers.fromOpenSSLCipherStrings8" \*#//1   r1N)r'r(r)r*rrrrNr0r1r2rGrGs&'F  r1rGzTLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:ECDH+AESGCM:ECDH+CHACHA20:DH+AESGCM:DH+CHACHA20:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS prime256v1c.eZdZdZdZdZdZdZdZy)ra Chooses the best elliptic curve for Elliptic Curve Diffie-Hellman key exchange, and provides a C{configureECDHCurve} method to set the curve, when appropriate, on a new L{OpenSSL.SSL.Context}. The C{configureECDHCurve} method will be set to one of the following based on the provided OpenSSL version and configuration: - L{_configureOpenSSL110} - L{_configureOpenSSL102} - L{_configureOpenSSL101} - L{_configureOpenSSL101NoCurves}. @param openSSLVersion: The OpenSSL version number. @type openSSLVersion: L{int} @see: L{OpenSSL.SSL.OPENSSL_VERSION_NUMBER} @param openSSLlib: The OpenSSL C{cffi} library module. @param openSSLcrypto: The OpenSSL L{crypto} module. @see: L{crypto} c||_||_|dk\r|j|_y|dk\r|j|_y |j t |_|j|_y#t$r|j|_YywxYw)Nii ) _openSSLlib_openSSLcrypto_configureOpenSSL110r'_configureOpenSSL102get_elliptic_curve_defaultCurveName_ecCurve_configureOpenSSL101r_configureOpenSSL101NoCurves)ropenSSLVersionrrs r2rz*_ChooseDiffieHellmanEllipticCurve.__init__Hs%+ Z '&*&?&?D # z )&*&?&?D # D - @ @AR S +/*C*C'  L+/*K*K' LsA**BBcy)z OpenSSL 1.1.0 Contexts are preconfigured with an optimal set of ECDH curves. This method does nothing. @param ctx: L{OpenSSL.SSL.Context} Nr0rrs r2rTz6_ChooseDiffieHellmanEllipticCurve._configureOpenSSL110Yrvr1ct|j} |jj|dy#t$rYywxYw)a Have the context automatically choose elliptic curves for ECDH. Run on OpenSSL 1.0.2 and OpenSSL 1.1.0+, but only has an effect on OpenSSL 1.0.2. @param ctx: The context which . @type ctx: L{OpenSSL.SSL.Context} TN)r rRSSL_CTX_set_ecdh_autor)rrctxPtrs r2rUz6_ChooseDiffieHellmanEllipticCurve._configureOpenSSL102as:     2 264 @   s + 77cZ |j|jy#t$rYywxYw)z Set the default elliptic curve for ECDH on the context. Only run on OpenSSL 1.0.1. @param ctx: The context on which to set the ECDH curve. @type ctx: L{OpenSSL.SSL.Context} N) set_tmp_ecdhrXrr]s r2rYz6_ChooseDiffieHellmanEllipticCurve._configureOpenSSL101ps+    T]] +   s  **cy)z No elliptic curves are available on OpenSSL 1.0.1. We can't set anything, so do nothing. @param ctx: The context on which to set the ECDH curve. @type ctx: L{OpenSSL.SSL.Context} Nr0r]s r2rZz>_ChooseDiffieHellmanEllipticCurve._configureOpenSSL101NoCurves}rvr1N) r'r(r)r*rrTrUrYrZr0r1r2rr,s!6D"    r1rc&eZdZdZdZedZy)OpenSSLDiffieHellmanParameterszn A representation of key generation parameters that are required for Diffie-Hellman key exchange. c||_yrM)r$)r parameterss r2rz'OpenSSLDiffieHellmanParameters.__init__s ! r1c||S)a Load parameters from a file. Such a file can be generated using the C{openssl} command line tool as following: C{openssl dhparam -out dh_param_2048.pem -2 2048} Please refer to U{OpenSSL's C{dhparam} documentation } for further details. @param filePath: A file containing parameters for Diffie-Hellman key exchange. @type filePath: L{FilePath } @return: An instance that loads its parameters from C{filePath}. @rtype: L{DiffieHellmanParameters } r0)rMfilePaths r2fromFilez'OpenSSLDiffieHellmanParameters.fromFiles*8}r1N)r'r(r)r*rrrjr0r1r2reres  "r1rec fd}syt}|tjzr'fd}|j||j ||tj zr#|j ||jyy)a Called to set up the L{OpenSSL.SSL.Context} for doing NPN and/or ALPN negotiation. @param context: The context which is set up. @type context: L{OpenSSL.SSL.Context} @param acceptableProtocols: The protocols this peer is willing to speak after the TLS negotiation has completed, advertised over both ALPN and NPN. If this argument is specified, and no overlap can be found with the other peer, the connection will fail to be established. If the remote peer does not offer NPN or ALPN, the connection will be established, but no protocol wil be negotiated. Protocols earlier in the list are preferred over those later in the list. @type acceptableProtocols: L{list} of L{bytes} cRt|tz}D] }||vs|cSy)at NPN client-side and ALPN server-side callback used to select the next protocol. Prefers protocols found earlier in C{_acceptableProtocols}. @param conn: The context which is set up. @type conn: L{OpenSSL.SSL.Connection} @param conn: Protocols advertised by the other side. @type conn: L{list} of L{bytes} r1)r)r> protocolsoverlapprs r2protoSelectCallbackz4_setAcceptableProtocols..protoSelectCallbacks9i.3':#;;$ AG| r1NcSrMr0)r>rs r2npnAdvertiseCallbackz5_setAcceptableProtocols..npnAdvertiseCallbacks & &r1)rrnror{set_npn_select_callbackrpr~set_alpn_protos)rrrp supportedrrs ` r2r(r(s~$0 -/I-111 ' **+?@''(;<-222(()<= 343r1)NNN)s __future__rrfbinasciir functoolsrhashlibrtypingrzope.interfacer r OpenSSLr r OpenSSL._utilr rr constantlyrrrr incrementalrtwisted.internet.abstractrrtwisted.internet.deferrtwisted.internet.errorrrtwisted.internet.interfacesrrrrtwisted.pythonrrtwisted.python.compatrtwisted.python.deprecaterr twisted.python.failurer!twisted.python.randbytesr"_idnar$r&r+rLr, OP_NO_TLSv1r- OP_NO_TLSv1_1r. OP_NO_TLSv1_2r/rrr> Exceptionr@rHrJrZrlrrr\rnrorxrrrhrrrrrrrr(rr6rrrrrrrrr@rirmsr1rrErGrNrrWrrer(r0r1r2rs #1- @@@+@ %.L*1  coo))))_d; 0i P2 L %"PJ6Q5R2!2    *""%?%C%CC$ >  * "6 " 0  " "aS%Z(aH&&R0IM(IMXFF*m m `9999xz iz z  * !! !(0> ++ +C!L@ ,-j.j..j.^ KG ! KG\ #$mm%m` * Ir1a "=*((**&* Ir1a "=*((**&  Wt$'  (  2&R&RR 3 S S   " " !" h*AA!X X vB95r1