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


Python ssl.PROTOCOL_TLSv1_1方法代码示例

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


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

示例1: convert_version2method

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_TLSv1_1 [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

示例2: get_ssl_version

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_TLSv1_1 [as 别名]
def get_ssl_version(sock):
        # Seth behaves differently depeding on the TLS protocol
        # https://bugs.python.org/issue31453
        # This is an ugly hack (as if the rest of this wasn't...)
    versions = [
        ssl.PROTOCOL_TLSv1,
        ssl.PROTOCOL_TLSv1_1,
        ssl.PROTOCOL_TLSv1_2,
        ]
    firstbytes = sock.recv(16, socket.MSG_PEEK)
    try:
        return versions[firstbytes[10]-1]
    except IndexError:
        print("Unexpected SSL version: %s" % hexlify(firstbytes))
        return versions[-1]


#  def launch_rdp_client():
#      time.sleep(1)
#      p = subprocess.Popen(
#          ["xfreerdp",
#           "/v:%s:%d" % (args.bind_ip, consts.RELAY_PORT),
#           "/u:%s\\%s" % (domain, user),
#          ],
#      ) 
开发者ID:SySS-Research,项目名称:Seth,代码行数:27,代码来源:main.py

示例3: get_default_ssl_version

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_TLSv1_1 [as 别名]
def get_default_ssl_version():
    """Get the highest support TLS version, if none is available, return None.

    :rtype: bool|None
    """
    if hasattr(ssl, 'PROTOCOL_TLSv1_2'):
        return ssl.PROTOCOL_TLSv1_2
    elif hasattr(ssl, 'PROTOCOL_TLSv1_1'):
        return ssl.PROTOCOL_TLSv1_1
    elif hasattr(ssl, 'PROTOCOL_TLSv1'):
        return ssl.PROTOCOL_TLSv1
    return None 
开发者ID:fake-name,项目名称:ReadableWebProxy,代码行数:14,代码来源:compatibility.py

示例4: rdp_connect

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_TLSv1_1 [as 别名]
def rdp_connect(self, ip_addr, port):
    s = socket.socket()
    s.connect((ip_addr, port))
    s.sendall(RDPClient.ConnectionRequestPDU())
    s.recv(1024)

    tls = ssl.wrap_socket(s, ssl_version=ssl.PROTOCOL_TLSv1_1)
    tls.sendall(RDPClient.ClientDataPDU())
    tls.recv(4096)

    tls.send(RDPClient.ErectDomainRequest())
    tls.sendall(RDPClient.AttactUserRequest())
    tls.recv(512)

    tls.sendall(RDPClient.ChannelJoinRequest(1007))
    tls.recv(1024)
    tls.sendall(RDPClient.ChannelJoinRequest(1003))
    tls.recv(1024)

    tls.sendall(RDPClient.ClientInfoPDU())
    res = b''
    res = tls.recv(512)

    if res != b'':
      return False
    return True 
开发者ID:johnnykv,项目名称:heralding,代码行数:28,代码来源:test_rdp.py

示例5: _get_tls_version

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_TLSv1_1 [as 别名]
def _get_tls_version(self,tlsString):
        switcher = {
            "tlsv1": ssl.PROTOCOL_TLSv1,
            "tlsv1.1": ssl.PROTOCOL_TLSv1_1,
            "tlsv1.2": ssl.PROTOCOL_TLSv1_2
        }
        return switcher.get(tlsString,ssl.PROTOCOL_TLSv1_2) 
开发者ID:monster1025,项目名称:aqara-mqtt,代码行数:9,代码来源:mqtt.py

示例6: get_default_ssl_version

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_TLSv1_1 [as 别名]
def get_default_ssl_version():
    """Get the highest support TLS version, if none is available, return None.

    :rtype: bool,None
    """
    if hasattr(ssl, 'PROTOCOL_TLSv1_2'):
        return ssl.PROTOCOL_TLSv1_2
    elif hasattr(ssl, 'PROTOCOL_TLSv1_1'):
        return ssl.PROTOCOL_TLSv1_1
    elif hasattr(ssl, 'PROTOCOL_TLSv1'):
        return ssl.PROTOCOL_TLSv1
    return None 
开发者ID:eandersson,项目名称:amqpstorm,代码行数:14,代码来源:compatibility.py

示例7: __init__

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_TLSv1_1 [as 别名]
def __init__(self, configuration_file, defaults=None):

        defaults = defaults or {}

        RawConfigParser.__init__(self)
        f = codecs.open(configuration_file, 'r', encoding='utf-8')
        self.read_file(f)
        f.close()

        ''' set defaults '''
        self.hostname     = 'localhost'
        self.port         = 1883
        self.username     = None
        self.password     = None
        self.clientid     = None
        self.lwt          = None
        self.skipretained = False
        self.cleansession = False
        self.protocol     = 3

        self.logformat    = '%(asctime)-15s %(levelname)-8s [%(name)-25s] %(message)s'
        self.logfile      = None
        self.loglevel     = 'DEBUG'

        self.functions    = None
        self.num_workers  = 1

        self.directory    = '.'
        self.ca_certs     = None
        self.tls_version  = None
        self.certfile     = None
        self.keyfile      = None
        self.tls_insecure = False
        self.tls          = False

        self.__dict__.update(defaults)
        self.__dict__.update(self.config('defaults'))

        if HAVE_TLS == False:
            logger.error("TLS parameters set but no TLS available (SSL)")
            sys.exit(2)

        if self.ca_certs is not None:
            self.tls = True

        if self.tls_version is not None:
            if self.tls_version == 'tlsv1_2':
                self.tls_version = ssl.PROTOCOL_TLSv1_2
            if self.tls_version == 'tlsv1_1':
                self.tls_version = ssl.PROTOCOL_TLSv1_1
            if self.tls_version == 'tlsv1':
                self.tls_version = ssl.PROTOCOL_TLSv1
            if self.tls_version == 'sslv3':
                self.tls_version = ssl.PROTOCOL_SSLv3

        self.loglevelnumber = self.level2number(self.loglevel)
        self.functions = load_functions(self.functions) 
开发者ID:jpmens,项目名称:mqttwarn,代码行数:59,代码来源:configuration.py

示例8: ssl_wrap_socket

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

        try:
            import ssl

            TLS_MAP = {}
            if hasattr(ssl, "PROTOCOL_TLSv1_2"):        # py3
                TLS_MAP[TLS_SECURE] = {
                    "tls1_2": ssl.PROTOCOL_TLSv1_2,
                    "tls1_1": ssl.PROTOCOL_TLSv1_1,
                }
            else:
                TLS_MAP[TLS_SECURE] = {}
            TLS_MAP[TLS_NO_SSL] = TLS_MAP[TLS_SECURE].copy()
            TLS_MAP[TLS_NO_SSL].update({
                "tls1": ssl.PROTOCOL_TLSv1,
            })
            TLS_MAP[TLS_COMPAT] = TLS_MAP[TLS_NO_SSL].copy()
            TLS_MAP[TLS_COMPAT].update({
                "ssl23": ssl.PROTOCOL_SSLv23,
                None: ssl.PROTOCOL_SSLv23,
            })
            if hasattr(ssl, "PROTOCOL_SSLv3"):          # Might not be available.
                TLS_MAP[TLS_COMPAT].update({
                    "ssl3": ssl.PROTOCOL_SSLv3
                })

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

            if self.tls_level not in TLS_MAP:
                raise RuntimeError("unknown tls_level: %s" % self.tls_level)

            if self.ssl_version not in TLS_MAP[self.tls_level]:
                raise socket.sslerror("Invalid SSL version '%s' requested for tls_version '%s'" % (self.ssl_version, self.tls_level))

            ssl_version =  TLS_MAP[self.tls_level][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("imaplib 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)

        # 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) 
开发者ID:OfflineIMAP,项目名称:imapfw,代码行数:57,代码来源:imaplib2.py

示例9: stage2

# 需要导入模块: import ssl [as 别名]
# 或者: from ssl import PROTOCOL_TLSv1_1 [as 别名]
def stage2():
    log.info("Starting stage2...")
    app = make_app()
    if not args.no_check_ip:
        net_valid = False
        conn_attempt = 0
        # check if machine has <args.serving_host> being assigned on any iface
        while True:
            conn_attempt += 1
            if args.serving_host in ip4ips():
                break
            else:
                if conn_attempt == 1:
                    log.info("** The IP address of <serve_host> ({}) is not assigned "
                        "to any interface on this machine.".format(args.serving_host))
                    log.info(
                        "** Please change WiFi network to {} and make sure {} is "
                        "being assigned to your WiFi interface.".format(
                            args.wifi_ssid, args.serving_host))
                    log.info("** This application should be kept running "
                        "and will wait until connected to the WiFi...")
                sleep(2)
                print(".", end="", flush=True)
                continue

    log.info("~~ Starting web server (HTTP port: %s, HTTPS port %s)" % (
        DEFAULT_PORT_HTTP, DEFAULT_PORT_HTTPS))

    # Ensure ProactorEventLoop not used on windows (not yet release in latest tornado)
    # https://github.com/python/pyperformance/pull/65/files
    if sys.platform == 'win32' and sys.version_info[:2] == (3, 8):
        import asyncio
        asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

    if args.legacy:
        old = make_app()
        # listening on port 8081 for serving upgrade files for older devices
        old.listen(8081)

    # listening on port 8080 for serving upgrade files
    app.listen(DEFAULT_PORT_HTTP)

    app_ssl = tornado.httpserver.HTTPServer(app, ssl_options={
        "certfile": resource_path("ssl/server.crt"),
        "keyfile": resource_path("ssl/server.key"),
        "ssl_version": ssl.PROTOCOL_TLSv1_1,
    })
    # listening on HTTPS port to catch initial POST request to eu-disp.coolkit.cc
    app_ssl.listen(DEFAULT_PORT_HTTPS)

    log.info("~~ Waiting for device to connect")

    stage3thread = threading.Thread(target=stage3, daemon=True)
    stage3thread.start()

    tornado.ioloop.IOLoop.instance().start() 
开发者ID:mirko,项目名称:SonOTA,代码行数:58,代码来源:sonota.py


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