コード例 #1
0
    def test_custom_context(self):
        # The following SSLContext doesn't provide any valid certicate.
        # Its purpose is only to confirm that hyper is not using its
        # default SSLContext.
        context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
        context.verify_mode = ssl.CERT_NONE
        context.check_hostname = False

        hyper.tls._context = context

        assert not hyper.tls._context.check_hostname
        assert hyper.tls._context.verify_mode == ssl.CERT_NONE
コード例 #2
0
ファイル: server.py プロジェクト: zofuthan/hyper
    def __init__(self, socket_handler, host='localhost', ready_event=None):
        threading.Thread.__init__(self)

        self.socket_handler = socket_handler
        self.host = host
        self.ready_event = ready_event

        self.cxt = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
        if ssl.HAS_NPN:
            self.cxt.set_npn_protocols([NPN_PROTOCOL])
        self.cxt.load_cert_chain(certfile='test/certs/server.crt',
                                 keyfile='test/certs/server.key')
コード例 #3
0
    def test_HTTPConnection_with_custom_context(self):
        context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
        context.set_default_verify_paths()
        context.verify_mode = ssl.CERT_REQUIRED
        context.check_hostname = True
        context.set_npn_protocols(['h2', 'h2-15'])
        context.options |= ssl.OP_NO_COMPRESSION

        conn = HTTPConnection('http2bin.org', 443, ssl_context=context)

        assert conn.ssl_context.check_hostname
        assert conn.ssl_context.verify_mode == ssl.CERT_REQUIRED
        assert conn.ssl_context.options & ssl.OP_NO_COMPRESSION != 0
コード例 #4
0
    def __init__(self,
                 socket_handler,
                 host='localhost',
                 ready_event=None,
                 h2=True,
                 secure=True):
        threading.Thread.__init__(self)

        self.socket_handler = socket_handler
        self.host = host
        self.secure = secure
        self.ready_event = ready_event
        self.daemon = True

        if self.secure:
            self.cxt = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
            if ssl.HAS_NPN and h2:
                self.cxt.set_npn_protocols([NPN_PROTOCOL])
            self.cxt.load_cert_chain(certfile='test/certs/server.crt',
                                     keyfile='test/certs/server.key')
コード例 #5
0
ファイル: server.py プロジェクト: darkcloud1801/hyper
    def __init__(self,
                 socket_handler,
                 host='localhost',
                 ready_event=None,
                 h2=True,
                 socket_security=SocketSecuritySetting.SECURE):
        threading.Thread.__init__(self)

        self.socket_handler = socket_handler
        self.host = host
        self.socket_security = socket_security
        self.ready_event = ready_event
        self.daemon = True

        if self.socket_security in (SocketSecuritySetting.SECURE,
                                    SocketSecuritySetting.SECURE_NO_AUTO_WRAP):
            self.cxt = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
            if ssl.HAS_NPN and h2:
                self.cxt.set_npn_protocols([NPN_PROTOCOL])
            self.cxt.load_cert_chain(certfile='test/certs/server.crt',
                                     keyfile='test/certs/server.key')