当前位置: 首页>>代码示例>>Python>>正文


Python ssl.CERT_NONE属性代码示例

本文整理汇总了Python中ssl.CERT_NONE属性的典型用法代码示例。如果您正苦于以下问题:Python ssl.CERT_NONE属性的具体用法?Python ssl.CERT_NONE怎么用?Python ssl.CERT_NONE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在ssl的用法示例。


在下文中一共展示了ssl.CERT_NONE属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: jenkins

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def jenkins(url, port):
    try:
        cli_port = False
        ctx = ssl.create_default_context()
        ctx.check_hostname = False
        ctx.verify_mode = ssl.CERT_NONE
        try:
            output = urllib2.urlopen('https://'+url+':'+port+"/jenkins/", context=ctx, timeout=8).info()
            cli_port = int(output['X-Jenkins-CLI-Port'])
        except urllib2.HTTPError, e:
            if e.getcode() == 404:
                try:
                    output = urllib2.urlopen('https://'+url+':'+port, context=ctx, timeout=8).info()
                    cli_port = int(output['X-Jenkins-CLI-Port'])
                except:
                    pass
        except:
            pass 
开发者ID:johndekroon,项目名称:serializekiller,代码行数:20,代码来源:serializekiller.py

示例2: start_server

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def start_server(port):
    # Start the server
    server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    server_socket.bind(('', port))
    server_socket.listen(128)  # Maximum connections Mac OSX can handle.

    status_messages.append(MESSAGE_INFO + "Successfully started the server on port {0}.".format(str(port)))
    status_messages.append(MESSAGE_INFO + "Waiting for clients...")

    while True:
        client_connection, client_address = ssl.wrap_socket(server_socket, cert_reqs=ssl.CERT_NONE, server_side=True, keyfile="server.key", certfile="server.crt").accept()

        status_messages.append(MESSAGE_INFO + "New client connected!")
        connections.append(client_connection) 
开发者ID:cys3c,项目名称:EvilOSX,代码行数:18,代码来源:Server.py

示例3: resolve_cert_reqs

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def resolve_cert_reqs(candidate):
    """
    Resolves the argument to a numeric constant, which can be passed to
    the wrap_socket function/method from the ssl module.
    Defaults to :data:`ssl.CERT_NONE`.
    If given a string it is assumed to be the name of the constant in the
    :mod:`ssl` module or its abbrevation.
    (So you can specify `REQUIRED` instead of `CERT_REQUIRED`.
    If it's neither `None` nor a string we assume it is already the numeric
    constant which can directly be passed to wrap_socket.
    """
    if candidate is None:
        return CERT_NONE

    if isinstance(candidate, str):
        res = getattr(ssl, candidate, None)
        if res is None:
            res = getattr(ssl, 'CERT_' + candidate)
        return res

    return candidate 
开发者ID:war-and-code,项目名称:jawfish,代码行数:23,代码来源:ssl_.py

示例4: resolve_cert_reqs

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def resolve_cert_reqs(candidate):
    """
    Resolves the argument to a numeric constant, which can be passed to
    the wrap_socket function/method from the ssl module.
    Defaults to :data:`ssl.CERT_NONE`.
    If given a string it is assumed to be the name of the constant in the
    :mod:`ssl` module or its abbreviation.
    (So you can specify `REQUIRED` instead of `CERT_REQUIRED`.
    If it's neither `None` nor a string we assume it is already the numeric
    constant which can directly be passed to wrap_socket.
    """
    if candidate is None:
        return CERT_NONE

    if isinstance(candidate, str):
        res = getattr(ssl, candidate, None)
        if res is None:
            res = getattr(ssl, 'CERT_' + candidate)
        return res

    return candidate 
开发者ID:danielecook,项目名称:gist-alfred,代码行数:23,代码来源:ssl_.py

示例5: __init__

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def __init__(self, host, port=None, key_file=None, cert_file=None,
                     strict=_strict_sentinel, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
                     source_address=None, **_3to2kwargs):
            if 'check_hostname' in _3to2kwargs: check_hostname = _3to2kwargs['check_hostname']; del _3to2kwargs['check_hostname']
            else: check_hostname = None
            if 'context' in _3to2kwargs: context = _3to2kwargs['context']; del _3to2kwargs['context']
            else: context = None
            super(HTTPSConnection, self).__init__(host, port, strict, timeout,
                                                  source_address)
            self.key_file = key_file
            self.cert_file = cert_file
            if context is None:
                # Some reasonable defaults
                context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
                context.options |= ssl.OP_NO_SSLv2
            will_verify = context.verify_mode != ssl.CERT_NONE
            if check_hostname is None:
                check_hostname = will_verify
            elif check_hostname and not will_verify:
                raise ValueError("check_hostname needs a SSL context with "
                                 "either CERT_OPTIONAL or CERT_REQUIRED")
            if key_file or cert_file:
                context.load_cert_chain(cert_file, key_file)
            self._context = context
            self._check_hostname = check_hostname 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:27,代码来源:client.py

示例6: resolve_cert_reqs

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def resolve_cert_reqs(candidate):
    """
    Resolves the argument to a numeric constant, which can be passed to
    the wrap_socket function/method from the ssl module.
    Defaults to :data:`ssl.CERT_NONE`.
    If given a string it is assumed to be the name of the constant in the
    :mod:`ssl` module or its abbreviation.
    (So you can specify `REQUIRED` instead of `CERT_REQUIRED`.
    If it's neither `None` nor a string we assume it is already the numeric
    constant which can directly be passed to wrap_socket.
    """
    if candidate is None:
        return CERT_REQUIRED

    if isinstance(candidate, str):
        res = getattr(ssl, candidate, None)
        if res is None:
            res = getattr(ssl, "CERT_" + candidate)
        return res

    return candidate 
开发者ID:remg427,项目名称:misp42splunk,代码行数:23,代码来源:ssl_.py

示例7: test_start_tls_smtp

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def test_start_tls_smtp(self):
        # This flow is simplified from RFC 3207 section 5.
        # We don't really need all of this, but it helps to make sure
        # that after realistic back-and-forth traffic the buffers end up
        # in a sane state.
        yield self.server_send_line(b"220 mail.example.com ready\r\n")
        yield self.client_send_line(b"EHLO mail.example.com\r\n")
        yield self.server_send_line(b"250-mail.example.com welcome\r\n")
        yield self.server_send_line(b"250 STARTTLS\r\n")
        yield self.client_send_line(b"STARTTLS\r\n")
        yield self.server_send_line(b"220 Go ahead\r\n")
        client_future = self.client_start_tls(dict(cert_reqs=ssl.CERT_NONE))
        server_future = self.server_start_tls(_server_ssl_options())
        self.client_stream = yield client_future
        self.server_stream = yield server_future
        self.assertTrue(isinstance(self.client_stream, SSLIOStream))
        self.assertTrue(isinstance(self.server_stream, SSLIOStream))
        yield self.client_send_line(b"EHLO mail.example.com\r\n")
        yield self.server_send_line(b"250 mail.example.com welcome\r\n") 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:21,代码来源:iostream_test.py

示例8: connect_to_server

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def connect_to_server(self, server_cls):
        server = client = None
        try:
            sock, port = bind_unused_port()
            server = server_cls(ssl_options=_server_ssl_options())
            server.add_socket(sock)

            client = SSLIOStream(socket.socket(),
                                 ssl_options=dict(cert_reqs=ssl.CERT_NONE))
            yield client.connect(('127.0.0.1', port))
            self.assertIsNotNone(client.socket.cipher())
        finally:
            if server is not None:
                server.stop()
            if client is not None:
                client.close() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:18,代码来源:iostream_test.py

示例9: _create_ssl_ctx

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def _create_ssl_ctx(self, sslp):
        if isinstance(sslp, ssl.SSLContext):
            return sslp
        ca = sslp.get('ca')
        capath = sslp.get('capath')
        hasnoca = ca is None and capath is None
        ctx = ssl.create_default_context(cafile=ca, capath=capath)
        ctx.check_hostname = not hasnoca and sslp.get('check_hostname', True)
        ctx.verify_mode = ssl.CERT_NONE if hasnoca else ssl.CERT_REQUIRED
        if 'cert' in sslp:
            ctx.load_cert_chain(sslp['cert'], keyfile=sslp.get('key'))
        if 'cipher' in sslp:
            ctx.set_ciphers(sslp['cipher'])
        ctx.options |= ssl.OP_NO_SSLv2
        ctx.options |= ssl.OP_NO_SSLv3
        return ctx 
开发者ID:MarcelloLins,项目名称:ServerlessCrawler-VancouverRealState,代码行数:18,代码来源:connections.py

示例10: myFunction

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def myFunction():
  # We create this context so that we can crawl 
  # https sites
  myssl = ssl.create_default_context();
  myssl.check_hostname=False
  myssl.verify_mode=ssl.CERT_NONE
  with Timer() as t:
    req = Request('https://tutorialedge.net', headers={'User-Agent': 'Mozilla/5.0'})
    response = urlopen(req, context=myssl)

  print("Elapsed Time: {} seconds".format(t.elapsed)) 
开发者ID:PacktPublishing,项目名称:Learning-Concurrency-in-Python,代码行数:13,代码来源:timeitContext.py

示例11: __init__

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def __init__(self, protocol_version):
            self.protocol = protocol_version
            # Use default values from a real SSLContext
            self.check_hostname = False
            self.verify_mode = ssl.CERT_NONE
            self.ca_certs = None
            self.options = 0
            self.certfile = None
            self.keyfile = None
            self.ciphers = None 
开发者ID:war-and-code,项目名称:jawfish,代码行数:12,代码来源:ssl_.py

示例12: jboss

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def jboss(url, port, retry=False):
    try:
        ctx = ssl.create_default_context()
        ctx.check_hostname = False
        ctx.verify_mode = ssl.CERT_NONE
        output = urllib2.urlopen(
            'https://' +
            url +
            ':' +
            port +
            "/invoker/JMXInvokerServlet",
            context=ctx,
            timeout=8).read()
    except:
        try:
            output = urllib2.urlopen(
                'http://' +
                url +
                ':' +
                port +
                "/invoker/JMXInvokerServlet",
                timeout=8).read()
        except:
            # OK. I give up.
            return False

    if "\xac\xed\x00\x05" in output:
        mutex.acquire()
        print " - (possibly) Vulnerable JBOSS: " + url + " (" + port + ")"
        saveToFile('[+] JBoss: ' + ':' + port + '\n')
        mutex.release()
        return True
    return False 
开发者ID:johndekroon,项目名称:serializekiller,代码行数:35,代码来源:serializekiller.py

示例13: connect

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import CERT_NONE [as 别名]
def connect(self):
        """Connect to vCenter server"""
        try:
            context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
            if self.config['no_ssl_verify']:
                requests.packages.urllib3.disable_warnings()
                context.verify_mode = ssl.CERT_NONE
                self.si = SmartConnectNoSSL(
                    host=self.config['server'],
                    user=self.config['username'],
                    pwd=self.config['password'],
                    port=int(self.config['port']),
                    certFile=None,
                    keyFile=None,
                )
            else:
                self.si = SmartConnect(
                    host=self.config['server'],
                    user=self.config['username'],
                    pwd=self.config['password'],
                    port=int(self.config['port']),
                    sslContext=context,
                    certFile=None,
                    keyFile=None,
                )
        except Exception as e:
            print('Unable to connect to vsphere server.')
            print(e)
            sys.exit(1)

        # add a clean up routine
        atexit.register(Disconnect, self.si)

        self.content = self.si.RetrieveContent() 
开发者ID:snobear,项目名称:ezmomi,代码行数:36,代码来源:ezmomi.py


注:本文中的ssl.CERT_NONE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。