python类_create_default_https_context()的实例源码

httplib.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def __init__(self, host, port=None, key_file=None, cert_file=None,
                     strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                     source_address=None, context=None):
            HTTPConnection.__init__(self, host, port, strict, timeout,
                                    source_address)
            self.key_file = key_file
            self.cert_file = cert_file
            if context is None:
                context = ssl._create_default_https_context()
            if key_file or cert_file:
                context.load_cert_chain(cert_file, key_file)
            self._context = context
httplib.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, host, port=None, key_file=None, cert_file=None,
                     strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                     source_address=None, context=None):
            HTTPConnection.__init__(self, host, port, strict, timeout,
                                    source_address)
            self.key_file = key_file
            self.cert_file = cert_file
            if context is None:
                context = ssl._create_default_https_context()
            if key_file or cert_file:
                context.load_cert_chain(cert_file, key_file)
            self._context = context
py_activesync_helper.py 文件源码 项目:peas 作者: mwrlabs 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def disable_certificate_verification():

    ssl._create_default_https_context = ssl._create_unverified_context
httplib.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __init__(self, host, port=None, key_file=None, cert_file=None,
                     strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                     source_address=None, context=None):
            HTTPConnection.__init__(self, host, port, strict, timeout,
                                    source_address)
            self.key_file = key_file
            self.cert_file = cert_file
            if context is None:
                context = ssl._create_default_https_context()
            if key_file or cert_file:
                context.load_cert_chain(cert_file, key_file)
            self._context = context
connect.py 文件源码 项目:AirMapSDK-Embedded 作者: airmap 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self):
        """Initialize connect find os set ssl context, get IP address

            :param None:
            :returns: None

        :todo: Add ifconfig command to try to get ip address
            """

        try:
            if self.os.name == 'nt':
                ssl.create_default_context()
            elif self.os.name == 'posix':
                ssl._create_default_https_context = ssl._create_unverified_context
            else:
                ssl._create_default_https_context = ssl._create_unverified_context

        except Exception,e:
            pass

        try:
            #print socket.gethostname()
            thisIP = "IP Address: " + socket.gethostbyname(socket.gethostname())
            #Globals.strPrint (self.thisGlobals, thisIP)

        except Exception,e:
            #Globals.strPrint (self.thisGlobals, "No IP Found...")
            pass
f5_utils.py 文件源码 项目:ansible_f5 作者: mcgonagle 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def bigip_api(bigip, user, password, validate_certs, port=443):
    try:
        if bigsuds.__version__ >= '1.0.4':
            api = bigsuds.BIGIP(hostname=bigip, username=user, password=password, verify=validate_certs, port=port)
        elif bigsuds.__version__ == '1.0.3':
            api = bigsuds.BIGIP(hostname=bigip, username=user, password=password, verify=validate_certs)
        else:
            api = bigsuds.BIGIP(hostname=bigip, username=user, password=password)
    except TypeError:
        # bigsuds < 1.0.3, no verify param
        if validate_certs:
            # Note: verified we have SSLContext when we parsed params
            api = bigsuds.BIGIP(hostname=bigip, username=user, password=password)
        else:
            import ssl
            if hasattr(ssl, 'SSLContext'):
                # Really, you should never do this.  It disables certificate
                # verification *globally*.  But since older bigip libraries
                # don't give us a way to toggle verification we need to
                # disable it at the global level.
                # From https://www.python.org/dev/peps/pep-0476/#id29
                ssl._create_default_https_context = ssl._create_unverified_context
            api = bigsuds.BIGIP(hostname=bigip, username=user, password=password)

    return api


# Fully Qualified name (with the partition)
ntap_util.py 文件源码 项目:netapp-ansible 作者: jeorryb 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def invoke_ssl_no_verify():
    try:
        _create_unverified_https_context = ssl._create_unverified_context

    except AttributeError:
    # Legacy Python that doesn't verify HTTPS certificates by default
        pass
    else:
    # Handle target environment that doesn't support HTTPS verification
        ssl._create_default_https_context = _create_unverified_https_context
ntap_util.py 文件源码 项目:netapp-ansible 作者: jeorryb 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def invoke_ssl_no_verify():
    try:
        _create_unverified_https_context = ssl._create_unverified_context

    except AttributeError:
    # Legacy Python that doesn't verify HTTPS certificates by default
        pass
    else:
    # Handle target environment that doesn't support HTTPS verification
        ssl._create_default_https_context = _create_unverified_https_context
CMSRecordingControl.py 文件源码 项目:Cisco-Showroom-RoomControl 作者: gbraux 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def GetCMSCallID(endpointUri):

    ssl._create_default_https_context = ssl._create_unverified_context
    conn = http.client.HTTPSConnection(Config.cmsFqdn)

    headers = {
        'authorization': Config.cmsGenericAuthRealm,
        'cache-control': "no-cache",
        'postman-token': "9620f24c-7e1e-36f2-cede-e016ef0641e4"
        }

    conn.request("GET", "/api/v1/calllegs", headers=headers)

    res = conn.getresponse()
    data = res.read()

    print(data.decode("utf-8"))

    tree = etree.fromstring(data)
    print(tree)

    callID = ""
    found = False
    for child in tree:
        for child2 in child:



            print(child2.tag)
            print(child2.attrib)
            print(child2.text)

            if ((child2.tag == "remoteParty") & (child2.text == endpointUri)):
                found = True 

            if ((child2.tag == "call") & (found == True)):
                return child2.text
bigip_facts.py 文件源码 项目:f5-aws-vpn 作者: f5devcentral 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def disable_ssl_cert_validation():
    # You probably only want to do this for testing and never in production.
    # From https://www.python.org/dev/peps/pep-0476/#id29
    import ssl
    ssl._create_default_https_context = ssl._create_unverified_context
GoProCamera.py 文件源码 项目:gopro-py-api 作者: KonradIT 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def pair(self):
        #This is a pairing procedure needed for HERO4 and HERO5 cameras. When those type GoPro camera are purchased the GoPro Mobile app needs an authentication code when pairing the camera to a mobile device for the first time. 
        #The code is useless afterwards. This function will pair your GoPro to the machine without the need of using the mobile app -- at all.
        print("Make sure your GoPro camera is in pairing mode!\nGo to settings > Wifi > PAIR > GoProApp to start pairing.\nThen connect to it, the ssid name should be GOPRO-XXXX/GPXXXXX/GOPRO-BP-XXXX and the password is goprohero")
        code=str(input("Enter pairing code: "))
        context = ssl._create_unverified_context()
        ssl._create_default_https_context = ssl._create_unverified_context
        response_raw = urllib.request.urlopen('https://10.5.5.9/gpPair?c=start&pin=' + code + '&mode=0', context=context).read().decode('utf8')
        print(response_raw)
        response_raw = urllib.request.urlopen('https://10.5.5.9/gpPair?c=finish&pin=' + code + '&mode=0', context=context).read().decode('utf8')
        print(response_raw)
        wifi_ssid=input("Enter your desired camera wifi ssid name: ")
        wifi_pass=input("Enter new wifi password: ")
        self.gpControlCommand("wireless/ap/ssid?ssid=" + wifi_ssid + "&pw=" + wifi_pass)
        print("Connect now!")
httplib.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __init__(self, host, port=None, key_file=None, cert_file=None,
                     strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                     source_address=None, context=None):
            HTTPConnection.__init__(self, host, port, strict, timeout,
                                    source_address)
            self.key_file = key_file
            self.cert_file = cert_file
            if context is None:
                context = ssl._create_default_https_context()
            if key_file or cert_file:
                context.load_cert_chain(cert_file, key_file)
            self._context = context
videoplayer.py 文件源码 项目:plugin.video.unofficial9anime 作者: Prometheusx-git 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def play(self):
        if self.link == '':
            return

        import urlresolver

        ''' 
            Kodi v17 updated to Python 2.7.10 from 2.7.5 in v16, which introduced this error when 
            trying to resolve the url:
            http://stackoverflow.com/questions/27835619/ssl-certificate-verify-failed-error

            In Kodi v16, python would not verify the SSL certs or at least ignore, but they changed
            with the upgrade to v17.  Sometimes the cert from the initial decrypted URL is invalid,
            so to avoid errors, we temporarily disable SSL to get the resolved URL.  Although this
            workaround isn't secure, I figure it's not any worse than before...
        '''
        try:
            url = urlresolver.resolve(self.link)
        except:
            helper.log_debug('Attempt to resolve URL failed; trying again with SSL temporarily disabled (v16 behavior)')
            import ssl
            default_context = ssl._create_default_https_context # save default context
            ssl._create_default_https_context = ssl._create_unverified_context
            url = urlresolver.resolve(self.link)
            ssl._create_default_https_context = default_context # restore default context

        helper.log_debug("UrlResolver's resolved link: %s" % url)
        helper.resolve_url(url)
httplib.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __init__(self, host, port=None, key_file=None, cert_file=None,
                     strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                     source_address=None, context=None):
            HTTPConnection.__init__(self, host, port, strict, timeout,
                                    source_address)
            self.key_file = key_file
            self.cert_file = cert_file
            if context is None:
                context = ssl._create_default_https_context()
            if key_file or cert_file:
                context.load_cert_chain(cert_file, key_file)
            self._context = context
httplib.py 文件源码 项目:land-leg-PY 作者: xfkencon 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self, host, port=None, key_file=None, cert_file=None,
                     strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                     source_address=None, context=None):
            HTTPConnection.__init__(self, host, port, strict, timeout,
                                    source_address)
            self.key_file = key_file
            self.cert_file = cert_file
            if context is None:
                context = ssl._create_default_https_context()
            if key_file or cert_file:
                context.load_cert_chain(cert_file, key_file)
            self._context = context
crawler.py 文件源码 项目:accurate_weibo_crawler 作者: wdwind 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def main():
    # log settings
    # log format
    #logging.basicConfig(level=logging.DEBUG, format='%(asctime)s [%(module)10s] [%(levelname)5s] %(message)s')

    #sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
    #sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
    #sys.stderr = codecs.getwriter('utf8')(sys.stderr)

    ssl._create_default_https_context = ssl._create_unverified_context

    config = init_config()
    if not config:
        return

    logger.log('[x] Weibo crawler v0.4', 'green')
    logger.log('[x] Configuration initialized')

    set_client(config['access_token'], config['expires_in'])
    response = login_private(config['access_token'])
    if response is None:
        logger.log('[x] User login fails.', 'red')
        return
    cookie = response['cookie']['cookie']['.weibo.com']
    config['cookie'] = cookie[4:cookie.index(';')]
    run(config)
httplib.py 文件源码 项目:empyrion-python-api 作者: huhlig 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __init__(self, host, port=None, key_file=None, cert_file=None,
                     strict=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                     source_address=None, context=None):
            HTTPConnection.__init__(self, host, port, strict, timeout,
                                    source_address)
            self.key_file = key_file
            self.cert_file = cert_file
            if context is None:
                context = ssl._create_default_https_context()
            if key_file or cert_file:
                context.load_cert_chain(cert_file, key_file)
            self._context = context
lbrynetservice.py 文件源码 项目:lbry-android 作者: lbryio 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def https_context():
    #urllib2
    try:
        _create_unverified_https_context = ssl._create_unverified_context
    except AttributeError:
        # Legacy Python that doesn't verify HTTPS certificates by default
        pass
    else:
        # Handle target environment that doesn't support HTTPS verification
        ssl._create_default_https_context = _create_unverified_https_context

    '''
    # requests
    from functools import partial
    class partialmethod(partial):
        def __get__(self, instance, owner):
            if instance is None:
                return self

            return partial(self.func, instance, *(self.args or ()), **(self.keywords or {}))

    default_request = requests.Session.request
    requests.Session.request = partialmethod(default_request, verify=False)
    '''

# LBRY Daemon
nltk_download.py 文件源码 项目:jenova 作者: dungba88 项目源码 文件源码 阅读 48 收藏 0 点赞 0 评论 0
def download():
    """skip unverified certificate and show download dialog"""
    try:
        create_unverified_https_context = ssl._create_unverified_context
    except AttributeError:
        pass
    else:
        ssl._create_default_https_context = create_unverified_https_context

    nltk.download()
f5_utils.py 文件源码 项目:ansible-provider-docs 作者: alibaba 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def bigip_api(bigip, user, password, validate_certs, port=443):
    try:
        if bigsuds.__version__ >= '1.0.4':
            api = bigsuds.BIGIP(hostname=bigip, username=user, password=password, verify=validate_certs, port=port)
        elif bigsuds.__version__ == '1.0.3':
            api = bigsuds.BIGIP(hostname=bigip, username=user, password=password, verify=validate_certs)
        else:
            api = bigsuds.BIGIP(hostname=bigip, username=user, password=password)
    except TypeError:
        # bigsuds < 1.0.3, no verify param
        if validate_certs:
            # Note: verified we have SSLContext when we parsed params
            api = bigsuds.BIGIP(hostname=bigip, username=user, password=password)
        else:
            import ssl
            if hasattr(ssl, 'SSLContext'):
                # Really, you should never do this.  It disables certificate
                # verification *globally*.  But since older bigip libraries
                # don't give us a way to toggle verification we need to
                # disable it at the global level.
                # From https://www.python.org/dev/peps/pep-0476/#id29
                ssl._create_default_https_context = ssl._create_unverified_context
            api = bigsuds.BIGIP(hostname=bigip, username=user, password=password)

    return api


# Fully Qualified name (with the partition)


问题


面经


文章

微信
公众号

扫码关注公众号