Ñò
Ç\äQc           @   sY  d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k l Z l Z d  d k l	 Z	 y d  d k
 Z
 Wn e j
 o d Z
 n Xd d d d d g Z d	 i ƒ  i ƒ  Z e Z Z xo d
 d d g f d d d g f f D]I \ Z Z x: e D]2 Z y d e e f d UWqe j
 o qXqWqð We
 d j	 o e e e f j Z y d  d k l Z Wn7 e j
 o+ e e d e ƒ  ƒ Z e d d „ Z n Xy d  d k
 l Z l Z Wn> e j
 o2 d e f d „  ƒ  YZ d d „ Z d „  Z n Xd e f d „  ƒ  YZ d e f d „  ƒ  YZ  d d „ Z! d a" d „  Z# d „  Z$ d S(    iÿÿÿÿN(   t   ResolutionErrort   ExtractionError(   t   urllib2t   VerifyingHTTPSHandlert   find_ca_bundlet   is_availablet
   cert_pathst
   opener_forsÄ   
/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
t   HTTPSHandlerR   s   urllib.requestt   HTTPSConnectiont   httplibs   http.clients   from %s import %s(   t   create_connectiont   _GLOBAL_DEFAULT_TIMEOUTc         C   s  |  \ } } d } xÕ t i | | d t i ƒ D]¸ } | \ } } }	 }
 } d } y` t i | | |	 ƒ } | t j	 o | i | ƒ n | o | i | ƒ n | i | ƒ | SWq. t j
 o( t	 } | d j	 o | i
 ƒ  qæ q. Xq. W| o ‚  n t d ƒ ‚ d S(   sˆ  Connect to *address* and return the socket object.

        Convenience function.  Connect to *address* (a 2-tuple ``(host,
        port)``) and return the socket object.  Passing the optional
        *timeout* parameter will set the timeout on the socket instance
        before attempting to connect.  If no *timeout* is supplied, the
        global default timeout setting returned by :func:`getdefaulttimeout`
        is used.  If *source_address* is set it must be a tuple of (host, port)
        for the socket to bind as a source address before making the connection.
        An host of '' or port 0 tells the OS to use the default.
        i    s!   getaddrinfo returns an empty listN(   t   Nonet   sockett   getaddrinfot   SOCK_STREAMR   t
   settimeoutt   bindt   connectt   errort   Truet   close(   t   addresst   timeoutt   source_addresst   hostt   portt   errt   rest   aft   socktypet   protot	   canonnamet   sat   sock(    (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyR   0   s*     (   t   CertificateErrort   match_hostnameR$   c           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyR$   X   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(    (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.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(   s7  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   getR8   t   matchR-   t   lenR$   R2   t   mapR,   (   t   certt   hostnamet   dnsnamest   sant   keyt   valuet   sub(    (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyR%   o   s4       &c           B   s    e  Z d  Z d „  Z d „  Z RS(   s=   Simple verifying handler: no auth, subclasses, timeouts, etc.c         C   s   | |  _  t i |  ƒ d  S(   N(   t	   ca_bundleR   t   __init__(   t   selfRI   (    (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyRJ   ±   s    	c            s   ˆ  i  ‡  f d †  | ƒ S(   Nc            s   t  |  ˆ  i |  S(    (   t   VerifyingHTTPSConnRI   (   R   t   kw(   RK   (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyt   <lambda>·   s    (   t   do_open(   RK   t   req(    (   RK   sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyt
   https_openµ   s    (   R&   R'   t   __doc__RJ   RQ   (    (    (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyR   ®   s   	RL   c           B   s    e  Z d  Z d „  Z d „  Z RS(   s@   Simple verifying connection: no auth, subclasses, timeouts, etc.c         K   s    t  i |  | |  | |  _ d  S(   N(   R	   RJ   RI   (   RK   R   RI   RM   (    (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyRJ   ½   s    c         C   s¥   t  |  i |  i f t |  d d  ƒ ƒ } t i | d t i d |  i ƒ|  _	 y t
 |  i	 i ƒ  |  i ƒ Wn6 t j
 o* |  i	 i t i ƒ |  i	 i ƒ  ‚  n Xd  S(   NR   t	   cert_reqst   ca_certs(   R   R   R   t   getattrR   t   sslt   wrap_sockett   CERT_REQUIREDRI   R#   R%   t   getpeercertR$   t   shutdownR   t	   SHUT_RDWRR   (   RK   R#   (    (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyR   Á   s    $(   R&   R'   RR   RJ   R   (    (    (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyRL   »   s   	c         C   s    t  i t |  p t ƒ  ƒ ƒ i S(   s@   Get a urlopen() replacement that uses ca_bundle for verification(   R   t   build_openerR   R   t   open(   RI   (    (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyR   Ï   s    c       	      sx   t  d  j	 o t  i Sy d d k l ‰  Wn t j
 o d  SXd ˆ  f ‡  f d †  ƒ  Y}  |  d d d g ƒ a  t  i S(   Niÿÿÿÿ(   t   CertFilet
   MyCertFilec              s   e  Z d d ‡  f d  † Z RS(   c            sL   ˆ  i  |  ƒ x | D] } |  i | ƒ q W|  i | ƒ t i |  i ƒ d  S(   N(   RJ   t   addstoret   addcertst   atexitt   registerR   (   RK   t   storest   certst   store(   R^   (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyRJ   ä   s     (    (    (   R&   R'   RJ   (    (   R^   (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyR_   ã   s   Rd   t   CAt   ROOT(   t	   _wincertsR   t   namet   wincertstoreR^   t   ImportError(   R_   (    (   R^   sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyt   get_win_certfileÙ   s    c       	   C   sy   t  i d j o t ƒ  Sx& t D] }  t  i i |  ƒ o |  Sq Wy t i d d ƒ SWn t t	 t
 f j
 o d SXd S(   s*   Return an existing CA bundle path, or Nonet   ntt   certifis
   cacert.pemN(   t   osRj   Rm   R   t   patht   isfilet   pkg_resourcest   resource_filenameRl   R    R   R   (   t	   cert_path(    (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyR   ï   s     	(%   t   sysRp   R   Rb   R.   Rs   R    R   t   setuptools.compatR   RV   Rl   R   t   __all__t   stripR*   R   t   objectR   R	   t   whatt   wheret   moduleR   R   RU   R   R$   R%   R=   R8   R   RL   R   Ri   Rm   R   (    (    (    sR   /var/www/html/kasc-wg8/erics/lib/python2.6/site-packages/setuptools/ssl_support.pyt   <module>   sP   <	

  $?	