ó
€
\c           @   sD   d  Z  d d l Z d Z d e f d „  ƒ  YZ 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__(    (    (    sl   /data/av2000/b2b/venv/lib/python2.7/site-packages/pip-1.3-py2.7.egg/pip/backwardcompat/ssl_match_hostname.pyR       s   c         C   sˆ   g  } x[ |  j  d ƒ D]J } | d k r8 | j d ƒ q t j | ƒ } | j | j d d ƒ ƒ q Wt j d d j | ƒ d t j ƒ S(	   Nt   .t   *s   [^.]+s   \*s   [^.]*s   \As   \.s   \Z(   t   splitt   appendt   ret   escapet   replacet   compilet   joint
   IGNORECASE(   t   dnt   patst   frag(    (    sl   /data/av2000/b2b/venv/lib/python2.7/site-packages/pip-1.3-py2.7.egg/pip/backwardcompat/ssl_match_hostname.pyt   _dnsname_to_pat
   s    c         C   sg  |  s t  d ƒ ‚ n  g  } |  j d d ƒ } xI | D]A \ } } | d k r4 t | ƒ j | ƒ re d S| j | ƒ q4 q4 W| së xi |  j d d ƒ D]R } xI | D]A \ } } | d k rŸ t | ƒ j | ƒ rÐ d S| j | ƒ qŸ qŸ Wq’ Wn  t | ƒ d k r(t d | d	 j t t	 | ƒ ƒ f ƒ ‚ n; t | ƒ d k rW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   mapt   repr(   t   certt   hostnamet   dnsnamest   sant   keyt   valuet   sub(    (    sl   /data/av2000/b2b/venv/lib/python2.7/site-packages/pip-1.3-py2.7.egg/pip/backwardcompat/ssl_match_hostname.pyt   match_hostname   s.    %(   t   __doc__R   t   __version__R   R    R   R"   (    (    (    sl   /data/av2000/b2b/venv/lib/python2.7/site-packages/pip-1.3-py2.7.egg/pip/backwardcompat/ssl_match_hostname.pyt   <module>   s
   	