Ñò
•èRc           @   sG   d  Z  d d k Z d Z d e f d „  ƒ  YZ d d „ Z d „  Z d S(	   sH   The match_hostname() function from Python 3.2, essential when using SSL.iÿÿÿÿNs   3.2a3t   CertificateErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sa   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/backwardcompat/ssl_match_hostname.pyR       s   i   c         C   sº   g  } x |  i  d ƒ D]| } | i d ƒ | j o t d t |  ƒ ƒ ‚ n | d j o | i d ƒ q t i | ƒ } | i | i d d ƒ ƒ q Wt i d d i	 | ƒ d	 t i
 ƒ S(
   Nt   .t   *s,   too many wildcards in certificate DNS name: s   [^.]+s   \*s   [^.]*s   \As   \.s   \Z(   t   splitt   countR    t   reprt   appendt   ret   escapet   replacet   compilet   joint
   IGNORECASE(   t   dnt   max_wildcardst   patst   frag(    (    sa   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/backwardcompat/ssl_match_hostname.pyt   _dnsname_to_pat
   s     c         C   sw  |  p t  d ƒ ‚ n g  } |  i d d ƒ } xM | D]E \ } } | d j o, t | ƒ i | ƒ o d S| i | ƒ q6 q6 W| pq xn |  i d d ƒ D]V } xM | D]E \ } } | d j o, t | ƒ i | ƒ o d S| i | ƒ q¦ q¦ Wq™ Wn t | ƒ d j o, t d | d	 i t t	 | ƒ ƒ f ƒ ‚ n> t | ƒ d j o t d
 | | d f ƒ ‚ n t d ƒ ‚ d S(   s#  Verify that *cert* (in decoded format as returned by
    SSLSocket.getpeercert()) matches the *hostname*.  RFC 2818 rules
    are mostly followed, but IP addresses are not accepted for *hostname*.

    CertificateError is raised on failure. On success, the function
    returns nothing.
    s   empty or no certificatet   subjectAltNamet   DNSNt   subjectt
   commonNamei   s&   hostname %r doesn't match either of %ss   , s   hostname %r doesn't match %ri    s=   no appropriate commonName or subjectAltName fields were found(    (    (
   t
   ValueErrort   getR   t   matchR   t   lenR    R   t   mapR   (   t   certt   hostnamet   dnsnamest   sant   keyt   valuet   sub(    (    sa   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/backwardcompat/ssl_match_hostname.pyt   match_hostname   s4       &(   t   __doc__R	   t   __version__R   R    R   R$   (    (    (    sa   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/pip/backwardcompat/ssl_match_hostname.pyt   <module>   s
   