a
hu! @ s d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dl m
Z
mZ zd dlZW n e
yj dZY n0 g dZd ZzejjZejjZW n ey e ZZY n0 eduoeeefvZzd dlmZmZ W nN e
y& zd dlmZ d dlmZ W n e
y dZdZY n0 Y n0 es>G dd d eZesVdddZd
d ZG dd deZG dd deZdddZ dd Z!e!dd Z"dd Z#dd Z$dS ) N)ResolutionErrorExtractionError)VerifyingHTTPSHandlerfind_ca_bundleis_available
cert_paths
opener_fora
/etc/pki/tls/certs/ca-bundle.crt
/etc/ssl/certs/ca-certificates.crt
/usr/share/ssl/certs/ca-bundle.crt
/usr/local/share/certs/ca-root.crt
/etc/ssl/cert.pem
/System/Library/OpenSSL/certs/cert.pem
/usr/local/share/certs/ca-root-nss.crt
/etc/ssl/ca-bundle.pem
)CertificateErrormatch_hostname)r )r
c @ s e Zd ZdS )r N)__name__
__module____qualname__ r r :/usr/lib/python3.9/site-packages/setuptools/ssl_support.pyr 7 s r c
C s g }| sdS | d}|d }|dd }|d}||krLtdt| |s`| | kS |dkrt|d n>|d s|d r|t| n|t| d
d |D ]}|t| qt
dd
| d tj} |
|S )zqMatching according to RFC 6125, section 6.4.3
https://tools.ietf.org/html/rfc6125#section-6.4.3
F.r r N*z,too many wildcards in certificate DNS name: z[^.]+zxn--z\*z[^.]*z\Az\.z\Z)splitcountr reprlowerappend
startswithreescapereplacecompilejoin
IGNORECASEmatch)
ZdnhostnameZ
max_wildcardsZpatspartsZleftmostZ remainderZ wildcardsfragpatr r r _dnsname_match= s,
r$ c C s | st dg }| dd}|D ]*\}}|dkr t||r@ dS || q |s| ddD ]6}|D ],\}}|dkrdt||r dS || qdq\t|dkrtd |d
tt|f n*t|dkrtd||d f ntd
dS )a= Verify that *cert* (in decoded format as returned by
SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 and RFC 6125
rules are followed, but IP addresses are not accepted for *hostname*.
CertificateError is raised on failure. On success, the function
returns nothing.
zempty or no certificateZsubjectAltNamer ZDNSNZsubjectZ
commonNamer z&hostname %r doesn't match either of %sz, zhostname %r doesn't match %rr z=no appropriate commonName or subjectAltName fields were found)
ValueErrorgetr$ r lenr r mapr )Zcertr ZdnsnamesZsankeyvaluesubr r r r
s s>
r
c @ s e Zd ZdZdd Zdd ZdS )r z=Simple verifying handler: no auth, subclasses, timeouts, etc.c C s || _ t| d S N) ca_bundleHTTPSHandler__init__)selfr- r r r r/ s zVerifyingHTTPSHandler.__init__c s fdd|S )Nc s t | jfi |S r, )VerifyingHTTPSConnr- )hostkwr0 r r