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


Python ssl.PROTOCOL_SSLv2方法代码示例

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


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

示例1: _connect

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_SSLv2 [as 别名]
def _connect(self, host, port, timeout, isssl=False):
        conn = None
        try:
            if isssl and not _SUPPORT_SSL:
                raise 'Not SUPPORT SSL'
            conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            conn.connect((host, port))
            if isssl:
                try:
                    conn = ssl.wrap_socket(conn, ssl_version=ssl.PROTOCOL_SSLv23)
                except ssl.SSLError as _:
                    conn.close()
                    conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                    conn.connect((host, port))
                    conn = ssl.wrap_socket(conn, ssl_version=ssl.PROTOCOL_SSLv2)

            conn.settimeout(timeout)
        except Exception as e:
            raise CurlError(Curl.CURLE_COULDNT_CONNECT)

        return conn 
开发者ID:w-digital-scanner,项目名称:w9scan,代码行数:23,代码来源:miniCurl.py

示例2: convert_version2method

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_SSLv2 [as 别名]
def convert_version2method(protocol_version):
    """
    Convert internal protocol version ID to Python SSL method.

    :param Integer protocol_version: Version ID
    :return: OpenSSL method or None if not found
    :rtype: OpenSSL method or None
    """
    if protocol_version == flextls.registry.version.SSLv2:
        return ssl.PROTOCOL_SSLv2
    if protocol_version == flextls.registry.version.SSLv3:
        return ssl.PROTOCOL_SSLv3
    if protocol_version == flextls.registry.version.TLSv10:
        return ssl.PROTOCOL_TLSv1
    if protocol_version == flextls.registry.version.TLSv11:
        return ssl.PROTOCOL_TLSv1_1
    if protocol_version == flextls.registry.version.TLSv12:
        return ssl.PROTOCOL_TLSv1_2

    return None 
开发者ID:DinoTools,项目名称:pysslscan,代码行数:22,代码来源:int_ssl.py

示例3: test_sslv2_fail

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_SSLv2 [as 别名]
def test_sslv2_fail(self):
            # This is really more of a client test, but run it here since
            # we've got all the other ssl version tests here.
            # Clients should have SSLv2 disabled by default.
            try:
                # The server simply closes the connection when it gets
                # an SSLv2 ClientHello packet.
                # request_timeout is needed here because on some platforms
                # (cygwin, but not native windows python), the close is not
                # detected promptly.
                response = self.fetch('/', request_timeout=1)
            except ssl.SSLError:
                # In some python/ssl builds the PROTOCOL_SSLv2 constant
                # exists but SSLv2 support is still compiled out, which
                # would result in an SSLError here (details vary depending
                # on python version).  The important thing is that
                # SSLv2 request's don't succeed, so we can just ignore
                # the errors here.
                return
            self.assertEqual(response.code, 599) 
开发者ID:omererdem,项目名称:honeything,代码行数:22,代码来源:httpserver_test.py

示例4: _connect

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_SSLv2 [as 别名]
def _connect(self, host, port, timeout, isssl = False):
        conn = None
        try:
            if isssl and not _SUPPORT_SSL:
                raise 'Not SUPPORT SSL'
            conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            conn.connect((host, port))
            if isssl:
                try:
                    conn = ssl.wrap_socket(conn, ssl_version=ssl.PROTOCOL_SSLv23)
                except ssl.SSLError as _:
                    conn.close()
                    conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                    conn.connect((host, port))
                    conn = ssl.wrap_socket(conn, ssl_version=ssl.PROTOCOL_SSLv2)

            conn.settimeout(timeout)
        except Exception as e:
            raise CurlError(Curl.CURLE_COULDNT_CONNECT)

        return conn 
开发者ID:nanshihui,项目名称:PocCollect,代码行数:23,代码来源:miniCurl.py

示例5: try_protocol_combo

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_SSLv2 [as 别名]
def try_protocol_combo(self, server_protocol, client_protocol):
        self._setup(ssl_protocol=server_protocol)
        self.client.ssl_version = client_protocol
        close_client(self.client)
        self.client.connect(self.server.host, self.server.port)
        try:
            self.client.login()
        except (ssl.SSLError, socket.error):
            self.client.close()
        else:
            self.client.quit()

    # def test_ssl_version(self):
    #     protos = [ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23,
    #               ssl.PROTOCOL_TLSv1]
    #     if hasattr(ssl, "PROTOCOL_SSLv2"):
    #         protos.append(ssl.PROTOCOL_SSLv2)
    #         for proto in protos:
    #             self.try_protocol_combo(ssl.PROTOCOL_SSLv2, proto)
    #     for proto in protos:
    #         self.try_protocol_combo(ssl.PROTOCOL_SSLv3, proto)
    #     for proto in protos:
    #         self.try_protocol_combo(ssl.PROTOCOL_SSLv23, proto)
    #     for proto in protos:
    #         self.try_protocol_combo(ssl.PROTOCOL_TLSv1, proto) 
开发者ID:giampaolo,项目名称:pyftpdlib,代码行数:27,代码来源:test_functional_ssl.py

示例6: ssl_wrap_socket

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_SSLv2 [as 别名]
def ssl_wrap_socket(self):

        # Allow sending of keep-alive messages - seems to prevent some servers
        # from closing SSL, leading to deadlocks.
        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)

        try:
            import ssl
            if self.ca_certs is not None:
                cert_reqs = ssl.CERT_REQUIRED
            else:
                cert_reqs = ssl.CERT_NONE

            if self.ssl_version == "tls1":
                ssl_version = ssl.PROTOCOL_TLSv1
            elif self.ssl_version == "ssl2":
                ssl_version = ssl.PROTOCOL_SSLv2
            elif self.ssl_version == "ssl3":
                ssl_version = ssl.PROTOCOL_SSLv3
            elif self.ssl_version == "ssl23" or self.ssl_version is None:
                ssl_version = ssl.PROTOCOL_SSLv23
            else:
                raise socket.sslerror("Invalid SSL version requested: %s", self.ssl_version)

            self.sock = ssl.wrap_socket(self.sock, self.keyfile, self.certfile, ca_certs=self.ca_certs, cert_reqs=cert_reqs, ssl_version=ssl_version)
            ssl_exc = ssl.SSLError
            self.read_fd = self.sock.fileno()
        except ImportError:
            # No ssl module, and socket.ssl has no fileno(), and does not allow certificate verification
            raise socket.sslerror("imaplib2 SSL mode does not work without ssl module")

        if self.cert_verify_cb is not None:
            cert_err = self.cert_verify_cb(self.sock.getpeercert(), self.host)
            if cert_err:
                raise ssl_exc(cert_err) 
开发者ID:Schibum,项目名称:sndlatr,代码行数:37,代码来源:imaplib2.py

示例7: test_ssl_version

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_SSLv2 [as 别名]
def test_ssl_version(self):
        protos = [ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1]
        if hasattr(ssl, "PROTOCOL_SSLv2"):
            protos.append(ssl.PROTOCOL_SSLv2)
            for proto in protos:
                self.try_protocol_combo(ssl.PROTOCOL_SSLv2, proto)
        for proto in protos:
            self.try_protocol_combo(ssl.PROTOCOL_SSLv3, proto)
        for proto in protos:
            self.try_protocol_combo(ssl.PROTOCOL_SSLv23, proto)
        for proto in protos:
            self.try_protocol_combo(ssl.PROTOCOL_TLSv1, proto) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:14,代码来源:test_functional_ssl.py

示例8: test_sslv2

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_SSLv2 [as 别名]
def test_sslv2(self):
            self.client.ssl_version = ssl.PROTOCOL_SSLv2
            self.client.close()
            self.client.connect(self.server.host, self.server.port)
            self.assertRaises(socket.error, self.client.login)
            self.client.ssl_version = ssl.PROTOCOL_SSLv2 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:8,代码来源:test_functional_ssl.py

示例9: open_ssl_socket

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_SSLv2 [as 别名]
def open_ssl_socket(version=ssl.PROTOCOL_SSLv2):
    pass 
开发者ID:PyCQA,项目名称:bandit,代码行数:4,代码来源:ssl-insecure-version.py

示例10: test_sslv2

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_SSLv2 [as 别名]
def test_sslv2(self):
            self.client.ssl_version = ssl.PROTOCOL_SSLv2
            close_client(self.client)
            if not OSX:
                with self.server.lock:
                    self.client.connect(self.server.host, self.server.port)
                self.assertRaises(socket.error, self.client.login)
            else:
                with self.server.lock:
                    with self.assertRaises(socket.error):
                        self.client.connect(self.server.host, self.server.port,
                                            timeout=0.1)
            self.client.ssl_version = ssl.PROTOCOL_SSLv2 
开发者ID:giampaolo,项目名称:pyftpdlib,代码行数:15,代码来源:test_functional_ssl.py


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